I am expanding a program that uses the I2C bus fairly heavily. In adding some new devices, I discovered that I had specified and incorrect address. In debugging it, I found that the I2C_Transfer() routine in FreeRTOS does not return any information indicating an error. The return value was merely 0.
The only clue that I had that something was wrong was that a read transfer did not change the value in memeory before the call.
Since failures of the bus are important in this case, how can the program determine that something went wrong on the bus?
xiangjun, David,
I've also ran into this issue. I posted a similar question and solution before I came across this post.
Ryan
Hi, David,
Can you tell us the part number you are using, where the IIC example is in SDK, the version of SDK, whether the IIC module is set up in slave mode or master mode?
Thank you
BR
Xiangjun Rong
I am running this on a FRDM-K22F board wired as per the readme.txt file found under:
C:\KSDK2\boards\frdmk22f\rtos_examples\freertos_i2c
With the wires connected as described it works. Remove either of the wires causing the I2C bus to fail and rather than reporting a failure, bogus values (0x00 or 0xFF) are reported.
I my situation, I was bringing up new hardware on my design. I knew the bus worked as I had several devices already operational. I was adding a new device and just happened to use the wrong address. That was when I found out that I didn't get an error code indicating a NAK condition as I had expected.