Hi, I'm writing code to stash variables in a modified 18x datalogger. The sample prog below counts up b12 and b13 so that they are clearly different, then sticks them into a pair of 512's. The LCD shows the number I expect but when I pull them out again the B12 is the same as B13?? What's going on??
init:
pause 1000
serout 6,N2400,(254,1)
let w2=20 ' change w2 value for number of readings
read 0,b2
read 1,b3
b13=0
b12=0
readD:
'readadc 1,b0
'readtemp 2,b1
pause 300
serout 6,N2400,(254,1,128,"P: ",#b12," ","T: ",#b13,254,192,"Adrs:",#w1,"/",#w2)
write1:
i2cslave %10100000, i2cfast, i2cword
writei2c w1,(b12)
pause 10
i2cslave %10100001, i2cfast, i2cword
writei2c w1,(b13)
inc:
pause 50
let w1=w1+1
write 0,b2
write 1,b3
if w1=w2 then full
b12 = b12+2
b13=b13+b12
goto readD
full:
high 2
datalink:
serout 6,N2400,(254,1,128,"Waiting for G"
serin 6, N4800,("G"
let w1=0
serout 6,N2400,(254,1,"Transfer..."
serout 7,N4800,("Address",44,"Amps",44,"Temp"," ",13,10)
read_data:
i2cslave %10100000, i2cfast, i2cword
readi2c w1,(b12)
pause 10
i2cslave %10100001, i2cfast, i2cword
readi2c w1,(b13)
pause 10
tx_data:
serout 7,N4800,(#w1,44,#b12,44,#b13,13,10)
let w1=w1+1
if w1=w2 then all_done
goto read_data
all_done:
low 2
serout 6,N2400,(254,1,128,"All done!"
serout 7,N4800,(0)
let w1=0
write 0,b2
write 0,b3
wait 5
end
Thanks for any suggestions.....
init:
pause 1000
serout 6,N2400,(254,1)
let w2=20 ' change w2 value for number of readings
read 0,b2
read 1,b3
b13=0
b12=0
readD:
'readadc 1,b0
'readtemp 2,b1
pause 300
serout 6,N2400,(254,1,128,"P: ",#b12," ","T: ",#b13,254,192,"Adrs:",#w1,"/",#w2)
write1:
i2cslave %10100000, i2cfast, i2cword
writei2c w1,(b12)
pause 10
i2cslave %10100001, i2cfast, i2cword
writei2c w1,(b13)
inc:
pause 50
let w1=w1+1
write 0,b2
write 1,b3
if w1=w2 then full
b12 = b12+2
b13=b13+b12
goto readD
full:
high 2
datalink:
serout 6,N2400,(254,1,128,"Waiting for G"
serin 6, N4800,("G"
let w1=0
serout 6,N2400,(254,1,"Transfer..."
serout 7,N4800,("Address",44,"Amps",44,"Temp"," ",13,10)
read_data:
i2cslave %10100000, i2cfast, i2cword
readi2c w1,(b12)
pause 10
i2cslave %10100001, i2cfast, i2cword
readi2c w1,(b13)
pause 10
tx_data:
serout 7,N4800,(#w1,44,#b12,44,#b13,13,10)
let w1=w1+1
if w1=w2 then all_done
goto read_data
all_done:
low 2
serout 6,N2400,(254,1,128,"All done!"
serout 7,N4800,(0)
let w1=0
write 0,b2
write 0,b3
wait 5
end
Thanks for any suggestions.....