Reading a 24 bit value using I2C
Hello,
I'm using a bs2px to read values from a Capacitance to Digital Converter. This CDC has 3 8 bit registers to store its digital results for a total of 24 bits. it is recommended to use an auto address incrementor to read the three successive registers to prevent a Done/Stop bit being sent to the CDC so the next measuremnt is not taken. Currently I'm using three I2COUT commands with changing address's but I know it's going to send a "done" after each of them. is there a way to avoid this? or setup an auto incrementor in a single I2C command? Below is the lines of code I have:
Thanks for your help
I'm using a bs2px to read values from a Capacitance to Digital Converter. This CDC has 3 8 bit registers to store its digital results for a total of 24 bits. it is recommended to use an auto address incrementor to read the three successive registers to prevent a Done/Stop bit being sent to the CDC so the next measuremnt is not taken. Currently I'm using three I2COUT commands with changing address's but I know it's going to send a "done" after each of them. is there a way to avoid this? or setup an auto incrementor in a single I2C command? Below is the lines of code I have:
I2CIN SDA,CDCRead,CapDataH,[noparse][[/noparse]STR CDCData \9 \E] 'Read current Capacitance measurement and store it in CDCData array I2CIN SDA,CDCRead,CapDataM,[noparse][[/noparse]STR CDCData(8) \9 \E] 'MSB = 0 I2CIN SDA,CDCRead,CapDataL,[noparse][[/noparse]STR CDCData(15) \9 \E]
Thanks for your help
Comments
I2CIN SDA, CDCRead, CapDataH, [noparse][[/noparse]CDCDataH, CDCDataM, CDCDataL]
where CDCDataH, CDCDataM, and CDCDataL are defined as byte variables.
The array is effectively only 3 bytes long and 8 bits are stored in each byte.
The ACK/NAK bit is set to ACK after the 1st two bytes and NAK after the last
which is as it should be. Normally most I2C interfaces will increment the
starting address after each byte is transferred.
If you really want to use an array, it needs to be defined as a 3 byte array and you'd use
I2CIN SDA, CDCRead, CapDataH, [noparse][[/noparse]STR CDCData \3]
Post Edited (Mike Green) : 5/30/2008 7:23:31 PM GMT