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

time out for i2c

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



Joined: 26 Apr 2006
Posts: 38
Location: Portugal

View user's profile Send private message

time out for i2c
PostPosted: Thu Sep 07, 2006 1:50 pm     Reply with quote

hi forum!!

i am using two PIC18F4525 and i implemented the code for multi byte send and receive. it works fine.
now i have a problem. in the slave i use the interruption.
because of other code, with interruption, at some point i need to turn off the ssp interruption.

the problem is that my master freezes, as the slave doesn't receive or answers. is there any way to make master work with time out??

some tips??

thanks!
Ttelmah
Guest







PostPosted: Thu Sep 07, 2006 2:51 pm     Reply with quote

Since a master generates the clock, and does not 'wait', it should not need a timeout. The key is that the slave will hold the ACK, till the byte is read in the code, and this can cause some of the supplied I2C routines to wait. The normal proceedure, is to verify that the slave is ready to receive, before proceeding. If you look at the thread entiled 'MCP3221', a few days ago, I posted a routine to read this chip, which does exactly this. It issues a dummy 'write', and verifies that the slave acknowledges this, before then issuing a repeated start, and the real transfer. Once a transaction has commenced, the slave should not lock out the I2C, till a transaction is complete. The same approach is used in most of the example IC files for various chips, with a read of the status register, or a dummy poll like this, before the transfer begins.
One approach you could use (since the I2C lines are using what are effectively open collector drives), if to have the slave pull the clock lne low, before going 'off line', and in the master, verify that this line is high, before initiating an I2C_START.
To do a genuine 'timeout', would depend on how your master routines are written. Obviously, if they are not interrupt driven, a timer interrupt, or even if they are interrupt driven, and you are using a 18 family chip, a high priority timer interrupt, could be used, but handling it tidyly, will be harder than making sure the slave is ready before a transfer.

Best Wishes
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