View previous topic :: View next topic |
Author |
Message |
eastvoltresearch
Joined: 02 Apr 2004 Posts: 3
|
What does the zero in i2c_read(0) mean? |
Posted: Fri Apr 02, 2004 9:57 pm |
|
|
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
|
|
Posted: Fri Apr 02, 2004 10:30 pm |
|
|
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 |
|
|
|