I am attempting to run this code.
Each block works perfectly on it's own.
When run, the screen clears and the time is displayed correctly. Nothing further happens and sertxd does not respond.
If I rem out the gosub get_time, the program loops OK, and sertxd shows regular updates.
However, if I change the loop order thus ...
Data first, then time, ALL performs OK, time and data updated regularly.
I thought at first some variable conflict. Any ideas?
Code:
'Station Base developement
'
'Vers 1 @ 10/10/12
#picaxe20m2
'#No_Data
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
init:
symbol LCD=b.6
symbol ANT=b.1
symbol ASK=b.2 'Conn to RX port
symbol ANS=b.3 'Conn to TX port
symbol HrHi=b18
symbol HrLo=b19
symbol MinHi=b20
symbol MinLo=b21
symbol DayHi=b22
symbol DayLo=b23
symbol MthHi=b24
symbol MthLo=b25
symbol YrHi=b26
symbol YrLo=b27
setfreq m16
pause 2000
serout LCD,N2400_16,(254,1,254,1)
pause 200
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
do
gosub get_time
pause 5000
gosub get_base
pause 5000
Loop
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
get_time:
i2cslave%11010000, i2cslow, i2cbyte
readi2c 1,(b1,b2,b3,b4,b5,b6)
pause 1000
bcdtoascii b2,HrHi,HrLo
bcdtoascii b1,MinHi,MinLo
bcdtoascii b4,DayHi,DayLo
bcdtoascii b5,MthHi,MthLo
bcdtoascii b6,YrHi,YrLo
serout LCD,N2400_16,(254,192,HrHi,HrLo,":",MinHi,MinLo)
serout LCD,N2400_16,(254,199,dayHi,DayLo,"/",MthHi,MthLo,"/",YrHi,YrLo)
pause 10000
return
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
get_base:
'First get pressure
setfreq m32
pause 500
serout ASK,t9600_32,("$sure p",$0D,$0A) 'Get pressure
serin ANS,t9600_32,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b1,b2,b3,b4,b5,b6,b7
setfreq m16
serout LCD,N2400_16,(254,128,b0,b1,b2,b3,b4,b5,b6)
sertxd ("Hg ",b0,b1,b2,b3,b4,b5,b6,cr,lf)
pause 500
'Now get temperature
setfreq m32
serout ASK,t9600_32,("$sure t-c",$0D,$0A) 'Get pressure
serin ANS,t9600_32,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b0,b4,b5,b6,b7,b8,b9
setfreq m16
serout LCD,N2400_16,(254,135,b4,b5,b6,b7,b8,b9)
sertxd (b4,b5,b6,b7,b8,b9,cr,lf)
pause 500
return
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
When run, the screen clears and the time is displayed correctly. Nothing further happens and sertxd does not respond.
If I rem out the gosub get_time, the program loops OK, and sertxd shows regular updates.
However, if I change the loop order thus ...
Code:
do
pause 5000
gosub get_base
pause 5000
gosub get_time
Loop
I thought at first some variable conflict. Any ideas?