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_poll() question

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



Joined: 28 Apr 2004
Posts: 14

View user's profile Send private message

i2c_poll() question
PostPosted: Wed Sep 19, 2007 2:50 am     Reply with quote

Hi !

I have a Problem with the I2C_poll() instruction.

I have a PIC that read a Temperature sensor via I2C, and I want to use the I2c_poll() function for a Timed out read.

I wrote the following code:
Code:

while(readIsNOTDone)
{
if(i2c_poll())
 {
    LM92MSB=i2c_read();
    readIsNOTDone=false;
    ReadTimeout=false;
 }
 else
 {
  if(TimeoutCounter++ > 64000)
     {
        ReadTimeout=true;
        readIsNOTDone=false;
     }
 }
}

if(ReadTimeout)
{
    i2c_stop();
    return(false);
}

The I2C settings are:
Code:

#use i2c(Master,FAST,sda=PIN_C4,scl=PIN_C3,force_hw)

but when I call i2c_poll() it returns always false and the function exit in time out.
Instead if I use immediately the i2c_read() I read the Temperature sensor correctly.

Why i2c_poll doesn't work ?

thanks
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Sep 19, 2007 9:04 am     Reply with quote

Read the help file regarding i2c_poll() again. It indicates that this function will only return a TRUE if the hardware has received a byte in the buffer. You're not doing anything to get a byte into the buffer. I've never used i2c_poll() before but I believe this function may be intended to be used in a PIC set up as a Slave.

Look over the data sheet, for the LM92, and see if there is any instructions on how to detect errors reading the sensor. Quite often you can tell if the sensor is talking/locked up by trying to talk to it and detecting an ACK.

Ronald
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