4 years, 6 months ago.

How to change the default timeout period of i2c read and write functions?

Is there any way of knowing the timeout of i2c read and write functions for master and slave. I found out it is around 32 ms from experiments. Is there any way in which this timeout can be changed? I am using I2C for communication between 2 FRDM-KL46Z micro controllers. Due to the low timeout period, the timing between read and write in the 2 micro-controllers are not getting sync. So I need to increase the timeout. Please help.

Comment on this question

1 Answer

4 years, 6 months ago.

I suppose you refer to the timeout on the slave ack on a master write operation (slave pulls SCL low until ready) ? I dont know the details of the KLxx I2C implementation but on the NXP mbeds the ack timeout is generallt handled by a simple delayloop and it is therefore not very consistent since it depends on the clockspeed. However, the code on some NXP platforms does not use a timeout and waits forever. You can inspect the mbed source code to see how it was implemented (i2c_api.c). In general the mbed I2C slave code is not easy to use and needs to be revised in my view. Maybe you can post your code to get more help on where it fails.


You need to log in to post a question