allenhuffman
Joined: 17 Jun 2019 Posts: 554 Location: Des Moines, Iowa, USA
|
PIC24 I2C Slave starts NAKing - can I reset the I2C somehow? |
Posted: Tue Dec 05, 2023 9:45 am |
|
|
I ran in to a situation where I had a stack of 8 PIC24 I2C slave devices and a few of them stopped ACKing writes to their address. I captured data with a Saleae analyzer and saw the first three responding as normal. All systems continue to operate (a heartbeat LED light blinks, watchdog timer has not reset the board).
I thought it might be useful to put in some kind of I2C reset in case the firmware has not had any I2C traffic after some period of time.
I use "#use i2c" to set up the I2C slave on these boards. Would "i2c_init( )" be appropriate to re-initialize the I2C hardware?
Would there be any way to detect this situation? Since the bus allows traffic to the other boards, I know it's not a slave doing clock stretching. I'm not sure what is going on with the 5 that are not responding (NAK). Since we have had this system in use and deployed for years, I don't think this is a common occurrence, but "since I've seen it once, it could happen again."
Suggestions appreciated. _________________ Allen C. Huffman, Sub-Etha Software (est. 1990) http://www.subethasoftware.com
Embedded C, Arduino, MSP430, ESP8266/32, BASIC Stamp and PIC24 programmer.
http://www.whywouldyouwanttodothat.com ? |
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Tue Dec 05, 2023 11:24 am |
|
|
A slave will do that if any of it's error bits is set.
So read the error bits and see what it going wrong. Probably either a bus
collision, or a receive overflow. Or a write collision (writing to a register
when the peripheral is busy).
Clearing the errors should make it start working again, but you need to
investigate 'why' they are getting set. |
|