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 support@ccsinfo.com

I2C Bus Recovery Question

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



Joined: 15 Mar 2005
Posts: 12

View user's profile Send private message

I2C Bus Recovery Question
PostPosted: Tue Apr 26, 2005 2:39 pm     Reply with quote

Greetings:

After much anguish, I have managed to pull together I2C code to handle multi-byte Master transmitter to Slave receiver messages (no big deal) AND multi-byte Slave transmitter to Master receiver (which was not at all obvious).

Error recovery at the Master receiver, however, is causing me no end of additional problems, and this is where I could use some sage advice.

I my Master receiver code, I, of course, start out with a address I2C_Write() with the address LSB set, then make successive calls to I2C_Read(Ack) until the very last byte to be read, with is retrieved with a call to I2C_Read(NoAck). This works very well until you test the code by halting the Slave transmitter from sending all the expected bytes, that is, I make a call to I2C_Read(Ack) for which there is no Slave response. Since the Ack is expected but does not occur, the I2C_Read(Ack) call locks up.

What is the proper method to reset the I2C bus in this case? I've read in a Philips publication hints of nine SCL cycles then clearing the SCL and SDA lines would behave as a reset, but I'm not quite sure how to implement this. I have tried to use a timer interrupt in which, if your not done I2Cing after an interval, you manually toggle the SCL/SDA lines, but I've had some curious timer interrupt behavior during I2C operations, which may be part of I2C or a whole other problem. Anyway, this seems extraordinarily brute force, such that I would hope there would be a more elegant solution. Are there any thoughts or suggestions from the I2C community?

Thanks,
Doug
Ttelmah
Guest







PostPosted: Tue Apr 26, 2005 3:41 pm     Reply with quote

If you are using the hardware I2C, look at I2C_POLL.
The 'clear' behaviour will depend on how your slave behaves. Normally a repeated I2C_START, will start a new transaction, but if the code has hung in the slave, it will be down to you having to recover from this (watchdog is perhaps the normal recovery option).

Best Wishes
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Wed Apr 27, 2005 6:56 am     Reply with quote

When you make the I2C_Read(Ack) that locks up the system, how are you halting the slave? The slave is probably holding the clock line low (stretching). CCS probably doesn't handle this very well. That is why I tend to shy away from their built in functions. You don't have control over them!
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