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

What does the zero in i2c_read(0) mean?

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



Joined: 02 Apr 2004
Posts: 3

View user's profile Send private message

What does the zero in i2c_read(0) mean?
PostPosted: Fri Apr 02, 2004 9:57 pm     Reply with quote

readData = i2c_read(0);

Could someone explain to me what the zero in the i2c_read(0) statement means and if it is needed ?

For example, i'm interfacing a MAX127 A/D converter and for the life of me i can't get it working.

The READ command for this IC is:

1. Send Address Byte
2. Send Control Byte
3. Receive MSB byte of data from MAX127
4. Receive LSB of data of data from MAX127

I'm using something like this:

i2c_start ();
i2c_write (0xzz);
i2c_write (0xzz);
analogvoltage.c[1] = i2c_read(0);
analogvoltage.c[0] = i2c_read(0);
i2c_stop ();

Is that right?




readData = i2c_read(0);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 10:30 pm     Reply with quote

Well, everything you ask is in the manual. The manual has no
table of contents, so I agree that it's hard to use. I've even
told them about it. I guess it's not a priority...

The '0' means don't do an ACK. If you look at the data sheet
for any i2c device, they usually show bit diagrams for all the
i2c transactions. On a read operation, they always show
no ack on the last byte that's read. So you need to do that.

I don't know if you have the demo or the full compiler. But with
the demo I think you don't get any examples or drivers.

Here's some test code that I've previously posted for the 24LC256.
Look specifically at the routine, read_eeprom_block(). Notice
that only the last i2c_read() gets a "no ack" parameter.
http://www.ccsinfo.com/forum/viewtopic.php?t=17036&highlight=24lc256
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