Problem using I2C bus
Posted: Mon Aug 24, 2009 12:22 am
I must use i2c bus of mod5270 but after try more more times i must ask you to help. I must have 4 analog input and i use Philips PCF8591 the schema is the same of link
http://foxlx.acmesystems.it/?id=10
The only change that i have apply is to add two pull-up resistors to SDA/SCL (4.7K value). the SDA is connected to j2-39 pin and SCL is connected to j2-42 pin.
The hardware is the same that i use in Rabbit module 2200 and working, in Netburner I can not read data bus. the source code of rabbit is the follow
int read_I2C(unsigned char address, char *buf, unsigned char len)
{
auto unsigned char cnt;
auto short int err;
i2c_stop_tx();
if (err=i2c_startw_tx()){
i2c_stop_tx();
return -1; }
if (err=i2c_wr_wait(0x90 | (address<<1))){
i2c_stop_tx();
return -1;
}
if (err=i2c_write_char(0x44)){
i2c_stop_tx();
return -1;
}
i2c_stop_tx();
if (err=i2c_startw_tx()) {
i2c_stop_tx();
return -1;
}
if (err=i2c_wr_wait(0x91 | (address<<1))){
i2c_stop_tx();
return -1;
}
i2c_read_char(&buf[cnt]);
i2c_send_ack();
for (cnt=0;cnt<len;cnt++)
{
err=i2c_read_char(&buf[cnt]);
if (err)
{
i2c_stop_tx();
return -1;
}
if (cnt==(len-1))
{
i2c_send_nak();
}
else
{
i2c_send_ack();
}
}
i2c_stop_tx();
return 1;
}
I have try to use the same code using I2CStart, I2CStop, I2CSend, I2CRead but not working, when i send 0x44 to databus i receive the I2C_NO_LINK_RX_ACK (9) error.
You can help me to develop the I2C bus reader for netburner?
Thank'you
Luca Borriero
http://foxlx.acmesystems.it/?id=10
The only change that i have apply is to add two pull-up resistors to SDA/SCL (4.7K value). the SDA is connected to j2-39 pin and SCL is connected to j2-42 pin.
The hardware is the same that i use in Rabbit module 2200 and working, in Netburner I can not read data bus. the source code of rabbit is the follow
int read_I2C(unsigned char address, char *buf, unsigned char len)
{
auto unsigned char cnt;
auto short int err;
i2c_stop_tx();
if (err=i2c_startw_tx()){
i2c_stop_tx();
return -1; }
if (err=i2c_wr_wait(0x90 | (address<<1))){
i2c_stop_tx();
return -1;
}
if (err=i2c_write_char(0x44)){
i2c_stop_tx();
return -1;
}
i2c_stop_tx();
if (err=i2c_startw_tx()) {
i2c_stop_tx();
return -1;
}
if (err=i2c_wr_wait(0x91 | (address<<1))){
i2c_stop_tx();
return -1;
}
i2c_read_char(&buf[cnt]);
i2c_send_ack();
for (cnt=0;cnt<len;cnt++)
{
err=i2c_read_char(&buf[cnt]);
if (err)
{
i2c_stop_tx();
return -1;
}
if (cnt==(len-1))
{
i2c_send_nak();
}
else
{
i2c_send_ack();
}
}
i2c_stop_tx();
return 1;
}
I have try to use the same code using I2CStart, I2CStop, I2CSend, I2CRead but not working, when i send 0x44 to databus i receive the I2C_NO_LINK_RX_ACK (9) error.
You can help me to develop the I2C bus reader for netburner?
Thank'you
Luca Borriero