CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24 I2C Slave starts NAKing - can I reset the I2C somehow?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
allenhuffman



Joined: 17 Jun 2019
Posts: 554
Location: Des Moines, Iowa, USA

View user's profile Send private message Visit poster's website

PIC24 I2C Slave starts NAKing - can I reset the I2C somehow?
PostPosted: Tue Dec 05, 2023 9:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Dec 05, 2023 11:24 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group