Other Parts Discussed in Thread: MSPM0G3507
Tool/software:
Hello,
I am trying to familiarize myself with the I2C peripheral within DriverLib. I am using the following example program to help me out: i2c_controller_rw_multibyte_fifo_poll_LP_MSPM0G3507_nortos_gcc
The example seems straight forward and not too complex to understand, but there were some questions that I had regarding the behavior of the code when a failure is present.
When I was testing the code, I forgot to set the correct I2C slave address for the device I am interfacing with. Because of this, I noticed the software got stuck in the for loop which waits for the RX FIFO to fill with the data expected from the slave node (see picture below).
This is problematic for my use case as this is technically now an infinite loop and will starve the rest of the program - not good. It seems like this can be mitigated by checking the ACK status of the target slave device before moving forward with reading the data.
With that being said,
- Is there a way to check if the sensor NACKs during the write part of the read transaction? This way you can safely prevent the software from trying to read from something that is not there. I looked through the DriverLib documentation and did not find anything.
- The DriverLib doesn't seem to provide any feedback regarding the status of each transaction. Are there any functions that can be called to get this information?
Another thing, the example program uses this while loop to ensure the I2C peripheral is not busy before moving onto the next step. In what situations can the software get stuck here and what are the solutions to this.
And finally, when reading from a sensor, is there a certain delay that should happen between the write and read transaction?
Thank you for your help! It is greatly appreciated.