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

24LC256 eeprom

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







24LC256 eeprom
PostPosted: Mon Jan 05, 2004 12:48 am     Reply with quote

Regarding the clock line for this eeprom, I constantly see that low level
routines TRISTATE to high impedance when bringing this line high. What is
the reason for this and wouldn´t setting the I/O pin to an output and then
setting it high do the same thing?. Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 05, 2004 2:42 am     Reply with quote

Quote:
Regarding the clock line for this eeprom, I constantly see that low level
routines TRISTATE to high impedance when bringing this line high.

This allows "clock stretching" by the slave device. This is possible
because the Master does not drive the SCL line high, but instead
it is brought high by a pull-up resistor.

From the i2c spec:
"On the byte level, a device may be able to receive bytes of
data at a fast rate, but needs more time to store a received
byte or prepare another byte to be transmitted. Slaves can
then hold the SCL line LOW after reception and
acknowledgment of a byte to force the master into a wait
state until the slave is ready for the next byte transfer in a
type of handshake procedure".

Here's the CCS code after the (software i2c) Master has transmitted
a byte to the slave device.

0023 BCF 06.1
0024 BSF 03.5 // Bank 1
0025 BCF 06.1
0026 NOP
0027 BSF 06.0
0028 NOP
0029 NOP
002A BSF 06.1 // Set SCL as an input pin

// Here's the loop where they test for clock stretching by the slave.
002B BCF 03.5 // Bank 0
002C BTFSC 06.1 // Test SCL pin. Skip next ins. if it = 0
002D GOTO 030 // If SCL = 0, exit this loop
002E BSF 03.5 // Bank 1
002F GOTO 02B // Jump back to the start of the test loop
0030 ...
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