PDA

View Full Version : I2CRead control value



DynamoBen
- 8th June 2005, 16:05
I'm currently using the following:

EEPromIndex var WORD

EEPromIndex=0
I2CRead SDA,SCL,rddev,EEPromIndex,[NextCard.HighByte,NextCard.LowByte]

One would think you could use the following w/o the variable and get the same results:

I2CRead SDA,SCL,rddev,0,[NextCard.HighByte,NextCard.LowByte]

However the program stalls out at that line if I go without the variable. Thoughts?

Dave
- 8th June 2005, 16:31
DynamoBen, It is probably because the immediate declaration of "0" is sized for 8 bits or 1 byte, as opposed to using the variable which is declared as a word for the eeprom addressing. That is why one should be carefull when using constants instead of variables.

Dave Purola,
N8NTA

Bruce
- 8th June 2005, 16:44
A word sized variable, even when it contains a value of 0, is still a 16-bit
value. PBP just clocks out 16 0's instead of 8.

Using an inline or direct value of 0 as the address argument with I2CRead
PBP is most likely interpreting this as an 8-bit address value, and clocking
out only 1/2 the required number of bits for the EEPROM address.

DynamoBen
- 8th June 2005, 17:05
I guess the variable stays then.