How do I read more than 1 byte using I2CIN?
Cheetah
Posts: 26
I'm interfacing to an ADS1000 chip using the BS2pe and I need to read 2 bytes of data from it.
The ADS1000 data sheet says that all I need to do is address the ads1000 for reading and just
read 2 bytes. I am able to one byte using the following pbasic statement:
but I don't know how to read 2 bytes. Can someone explain to me how to read more than
one byte using I2CIN?
Thanks.
The ADS1000 data sheet says that all I need to do is address the ads1000 for reading and just
read 2 bytes. I am able to one byte using the following pbasic statement:
I2CIN SDA, RdADS, 0, [noparse][[/noparse]result]
but I don't know how to read 2 bytes. Can someone explain to me how to read more than
one byte using I2CIN?
Thanks.
Comments
serStr· VAR···· Byte(10)······················· ' Make a 10-byte array
Main:
· serStr(9) = 0·································· ·' Put 0 in last byte
··SERIN 1, 16468, [noparse][[/noparse]STR serStr\9]············' Get 9-byte string
· DEBUG STR serString··························' Display the string
· END
Or in your case:
Define a word variable (2 bytes) and:
I2CIN 1, 16468, [noparse]/noparse]DEC2 [i]varname[/i
If the device will send a 16-bit value it will most likely be sent as two bytes. You need to know how the device will send these 2 bytes (in what order, usually HIGHBYTE/LOWBYTE). Once you know that you can do something like.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
http://forums.parallax.com/showthread.php?p=562370
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support