Im TXing serial data to the scratch pad of a 40X1 via the hserin in auto mode. The program then looks through the scratch pad for a string of data in the correct sequence that indicates to it that this Rf tx is from one of its senders.
I then use one part of the string in the branch command to indicate where the program should go next.
Problem is that the program doesnt recognise the byte value in the branch command. It seems that the byte value is corrupted during the scratch pad write/read process.
Heres the code, Im a bit perplexed.
The branch comm works fine if I 'manually' set the b2 value with command " b2=7". I debug b2 after the 'get 101,b2' command and it shows b2 as holding 7 yet the branch command doesnt recognise the 7.
Any pointers anyone?
I then use one part of the string in the branch command to indicate where the program should go next.
Problem is that the program doesnt recognise the byte value in the branch command. It seems that the byte value is corrupted during the scratch pad write/read process.
Heres the code, Im a bit perplexed.
The branch comm works fine if I 'manually' set the b2 value with command " b2=7". I debug b2 after the 'get 101,b2' command and it shows b2 as holding 7 yet the branch command doesnt recognise the 7.
Any pointers anyone?
Code:
setfreq m4
hsersetup B1200_4,%11
setintflags %00100000,%00100000
armed:
high 0 'flash led
pause 50
low 0
pause 50
if b20 = 1 then goto check_for_valid_data
goto armed
check_for_valid_data:
b20=0 'set b20 to zero so program knows it been here to check the scratch pad
ptr=0
for b0 = 1 to 90
if @ptr="#" then goto next_check2
inc ptr
next b0
ptr=0
setintflags %00100000,%00100000
goto armed
next_check2:
put 100,@ptr
inc ptr
if @ptr="7" then goto next_check3
ptr=0
setintflags %00100000,%00100000
goto armed
next_check3:
put 101,@ptr
inc ptr
if @ptr="^" then goto valid_alarm
ptr=0
setintflags %00100000,%00100000
goto armed
valid_alarm:
put 102,@ptr
sertxd ("valid alarm")
get 101,b2
branch b2,(null,sensor1,sensor2,sensor3,sensor4,sensor5,sensor6,sensor7,sensor8,sensor9,sensor10) 'use the loaded b2 value with the branch comm to go to the right sensor learning subroutine
cont:
setintflags %00100000,%00100000
goto armed
null:
goto cont
sensor1:
b1=1
write 1,b1
goto cont
sensor2:
b1=1
write 2,b1
goto cont
sensor3:
b1=1
write 3,b1
goto cont
sensor4:
b1=1
write 4,b1
goto cont
sensor5:
b1=1
write 5,b1
goto cont
sensor6:
b1=1
write 6,b1
pause 2000
goto cont
sensor7:
b1=1
write 7,b1
sertxd ("just wrote byte value to eeprom")
pause 2000
goto cont
sensor8:
b1=1
write 8,b1
pause 2000
goto cont
sensor9:
b1=1
write 9,b1
goto cont
sensor10:
b1=1
write 10,b1
goto cont
interrupt:
sertxd ("hserin triggered")
b20=1
return
Last edited by a moderator: