fernando_g
Senior Member
Let me see if I'm getting my facts straight.
-A 24LC256 EEPROM has 261568 individual bits or 32696 bytes.
-Which means it has 32696 individual addresses
-Which means that if I want to store 5 byte variables, I should partition the memory in blocks of 6540 individual adresses.
So far so good?
Therefore the code to sequentially write these variables must look something like this:
So far so good?
And to sequentially send the data to the computer, then my code would be:
-A 24LC256 EEPROM has 261568 individual bits or 32696 bytes.
-Which means it has 32696 individual addresses
-Which means that if I want to store 5 byte variables, I should partition the memory in blocks of 6540 individual adresses.
So far so good?
Therefore the code to sequentially write these variables must look something like this:
Code:
low EEProt ' write enable eeprom
i2cslave %10100000, i2cslow, i2cword 'EEPROM
writei2c address,(cor_temp) 'partition the memory's 32696 addresses
pause 10
tmpwd1 = address + 6540
writei2c tmpwd1,(lowind)
pause 10
tmpwd1 = address + 13080
writei2c tmpwd1,(hiwind)
pause 10
tmpwd1 = address + 19620
writei2c tmpwd1,(cor_RH)
pause 10
tmpwd1 = address + 26160
writei2c tmpwd1,(light)
pause 10
'increment address
inc_address:
let address = address + 1
if address < 6540 then not_finish
And to sequentially send the data to the computer, then my code would be:
Code:
index = 0
transmit_data:
i2cslave %10100000, i2cslow, i2cword 'EEPROM
readi2c index,(cor_temp)
tmpwd1 = index + 6540
readi2c tmpwd1,(lowind)
tmpwd1 = index + 13080
readi2c tmpwd1,(hiwind)
tmpwd1 = address + 19620
readi2c tmpwd1,(cor_RH)
tmpwd1 = address + 26160
readi2c tmpwd1,(light)
Sertxd (#index,COM,#cor_temp,COM,#lowind,COM,#hiwind,COM,#cor_RH,COM,#light,COM,RET,LFEED) 'the red led will show acivity
let index = index + 1
if index > 6540 then all_done 'stop transmitting when that condition is met
goto transmit_data
all_done: 'finished so send NULL
Sertxd(0)