word variable problem

sok_nou

New Member
im using the 28X1 connected to 4 max6674 thermocouple converters in spi mode. i use it as a datalogger. i store the data in 4 24lc256 in i2c mode. for more than one year ive written 10 different codes that worked. the problem is that now i did some hardware improvements and tried the new code it just cant write and read word variables on the eeproms.

i used the old code but the problem continues
i used the old hardware that was working fine for one year but now i cant write even on that.

i used a simple code just to see whats going on with the memories. when i use variables that are no more than a byte value everything is ok but when the value goes more than a byte the problem starts,

anybody had the same problem?
init:
pause 300

main:

w1 = 260
i2cslave %10100000, i2cfast, i2cword
writei2c w0, (w1)
pause 30
sertxd (#w1,13,10)

i2cslave %10100000, i2cfast, i2cword
readi2c w0, (w2)
pause 30
sertxd (#w2,13,10)

if i set w1=34 or anything less than 255 it works fine.
 

Technical

Technical Support
Staff member
You can't write words to the i2c bus - never have been able to as this how the i2c bus works!

Even if the address specification is a word, you still have to read/write byte variables. w1 is the two bytes b2 and b3, so you want
writei2c w0, (b2,b3)
instead of
writei2c w0, (w1)
 

westaust55

Moderator
i2c data width

in the statement:
i2cslave %10100000, i2cfast, i2cword​

the term i2cword relates to the address width only.

some devices including smaller EEPROMs such as the 24C16 use byte width adressing only. See the HI2CSETUP command in manual 2 at page 53 has a table giving speeds and address widths,

as Technical has stated the data is always handled in bytes.
 
Top