resetting the I2C bus

Discussion to talk about software related topics only.
Post Reply
bstark
Posts: 10
Joined: Thu Jun 26, 2008 10:36 am

resetting the I2C bus

Post by bstark »

I am monitoring devices using the I2C bus. On one of our delivered systems we are seeing an intermittent error on the I2C bus, when this happens we are unable to communicate on the I2C bus at all. Power cycling our device seems to clear the problem until the next intermittent error. The point of monitoring our device is to minimize downtime by identifying issues that can be corrected without bringing the whole system down. Since power cycling seems to fix the issue I am wondering if I simply reset the I2C bus that may fix the problem as well. I am using the I2C support functions, if I call I2CInit, will this effectively reset the I2C bus?
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: resetting the I2C bus

Post by lgitlitz »

Power cycling the NetBurner or the connected I2C slave? Calling I2Cinit should reset all of the I2C stuff on the NetBurner side. This will disable the peripheral, reconfigure it and then re-enable. This will not do anything to get a stuck slave device back to life. The only thing I can think of that might recover a stuck slave is sending a stop command on the bus ( I2CStop(); ). The device may think it is still in the middle of a transaction and all slaves should release from active communication when they see a stop command. Is this slave device a common sensor? Are you running the I2C past 100KHz? Do you have proper pull-ups on the bus? How long are the bus wires?
User avatar
yevgenit
Posts: 84
Joined: Fri Apr 25, 2008 12:47 am
Contact:

Re: resetting the I2C bus - fix

Post by yevgenit »

Sending a STOP Condition from NetBurner side can be obstructed, if any slave device, which thinks it is still in the middle of a byte transmit, holds SDA line down. If this case is detected, the solution is to send a few bits with value "one", until the stuck device sends bit with value "one", thus releasing SDA line. At this moment, STOP Condition can be sent successfully.

Update: sorry for previous mention of bit ACK as value "one".

Update: in case of the external master device holds line SCK down, use I2C procedure of arbitration.
Yevgeni Tunik
Embedded/RealTime software engineer
https://www.linkedin.com/in/yevgenitunik/
________________________
User avatar
yevgenit
Posts: 84
Joined: Fri Apr 25, 2008 12:47 am
Contact:

Re: resetting the I2C bus - fix

Post by yevgenit »

The following method of I2C software reset is recommended by Atmel:
(Taken from http://www.atmel.com/dyn/resources/prod ... oc5297.pdf)

Software Reset: After an interruption in protocol, power loss or system reset, any 2-wire
part can be protocol reset by following these steps: (a) Create a start bit condition, (b)
clock 9 cycles, (c) create another start bit followed by stop bit condition as shown below.
The device is ready for next communication after above steps have been completed.


See also "Figure 3-1. Protocol Reset Condition" in above file.
Yevgeni Tunik
Embedded/RealTime software engineer
https://www.linkedin.com/in/yevgenitunik/
________________________
Post Reply