View previous topic :: View next topic |
Author |
Message |
alexbilo
Joined: 01 Jun 2004 Posts: 39 Location: Trois-Rivières
|
Another I2C question - i2c_read() action |
Posted: Thu Jun 03, 2004 5:21 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Jun 04, 2004 8:18 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Jun 08, 2004 8:52 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Jun 08, 2004 8:54 am |
|
|
I'm sorry, I was talking about I2C_Write in a slave! ![Embarassed](images/smiles/icon_redface.gif) |
|
![](templates/subSilver/images/spacer.gif) |
alexbilo
Joined: 01 Jun 2004 Posts: 39 Location: Trois-Rivières
|
Question still open |
Posted: Tue Jun 08, 2004 11:53 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Wed Jun 09, 2004 1:41 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|