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

Another I2C question - i2c_read() action

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



Joined: 01 Jun 2004
Posts: 39
Location: Trois-Rivières

View user's profile Send private message

Another I2C question - i2c_read() action
PostPosted: Thu Jun 03, 2004 5:21 pm     Reply with quote

Hi,

I'd like to know what happens when I call the i2c_read() function in a slave configured PIC18F452. I saw in the help that this function takes ACK as an argument (to set if an ACK is sent or not). However, I thought that the ack bit was sent as soon as the received byte entered the SSPSR register, not when I actually read the value in the SSPBUF (if it's really what this function does).

Thanks,
_________________
Alex
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Jun 04, 2004 8:18 am     Reply with quote

I haven't tried using i2c_read() in a slave yet so I could be wrong on this but I don't think that a slave would use this function. A master would use this to try to get information from other slaves. A Master is the one that controls the SCL line and the i2c_read() is trying to read data from another device.
Guest








PostPosted: Tue Jun 08, 2004 8:52 am     Reply with quote

The I2C_Read() function uses clock stretching.

This means a thousand lines of code can be executed in the slave before it sends a byte to the master, as long as it holds the clock low.

Look in the datasheet and your listing for the use of the CKP bit.
Guest








PostPosted: Tue Jun 08, 2004 8:54 am     Reply with quote

I'm sorry, I was talking about I2C_Write in a slave! Embarassed
alexbilo



Joined: 01 Jun 2004
Posts: 39
Location: Trois-Rivières

View user's profile Send private message

Question still open
PostPosted: Tue Jun 08, 2004 11:53 am     Reply with quote

Well, what I want to know exactly is the use of the ack parameter in the i2c_read(ack) function. Since the ack bit is sent on the last clock pulse, should I call the i2c_read function before the actual data arrives or can I call this function to read the data once it's in the buffer?

Thanks
_________________
Alex
Guest








PostPosted: Wed Jun 09, 2004 1:41 am     Reply with quote

In paragraph 15.4.3.2 of the PIC18FXX2 datasheet, the use of clock stretching is explained. Maybe CSS uses clock stretching also for the slave read. That's something I don't know. You'll have to find out.
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