Jacob11
Occasional Contributor
3 years agoNios 2 I2c timeout altera_avalon_i2c.c - timeout never occurs
Hi gang.
I am using the altera avalon i2c driver for communication to peripheral devices on my board.
I want to read from different i2c addresses to determine if a device is present.
For instance a small code snippet:
rt = i2c_read_reg(I2C_EXT, 0x00, 0x00, &i2cRead, 8);
//i2c_read_reg(i2cBus, i2cAddress, register, *data buffer, bitwidth)
if (rt == ALT_AVALON_I2C_SUCCESS)
{
printf("INFO: Device found at address 0x00);
}
else
{
printf("INFO: no device exists at address 0x00");
}
The issue is that when a device is at the address, everything works.
But if the device does not exist at the given address, the program
just freezes. It doesn't actually timeout and return an error code
like it is supposed to.
Is there any workaround?? I need to test 127 addresses. I can already
accomplish this with a write operation, but I do not want to write anything
since some of these are memory chips with specific functions. A simple
read allows me to accomplish this much better.
Any ideas here??
What I have already tried is to lower the timeout variables in the driver
from 10000 to 100 and that also did not seem to do anything. The program just
freezes when trying to read from an address with no hardware attached.
Thanks
Jacob