Hi,
I'm starting to get the hang of serial coms using my 14m2 chip, but now I'm trying to grasp the concept of background receive on a 20x2.
Before I go ahead and spend weeks writing a program, does my code below look like a good starting point, or am I asking for trouble with data loss at 9600 baud?
I intend to expand the code to use the ptr to locate a string, possibly by using the last byte in the string to step back and read out the whole string from the buffer.
I have spent hours reading posts and Picaxe manuals so I apologise in advance if none of it sunk in and I haven't understood the concept
I'm starting to get the hang of serial coms using my 14m2 chip, but now I'm trying to grasp the concept of background receive on a 20x2.
Before I go ahead and spend weeks writing a program, does my code below look like a good starting point, or am I asking for trouble with data loss at 9600 baud?
I intend to expand the code to use the ptr to locate a string, possibly by using the last byte in the string to step back and read out the whole string from the buffer.
Code:
symbol RAD_LED = B.0
symbol BMBO_LED = B.1
symbol MFL_LED = B.2
#picaxe 20x2 'suitable chip with a large background Rx buffer
Init:
'listen on pin B.6 (leg 11)
hsersetup B9600_8, %110
setintflags %00100000,%00100000
Main:
Do
pause 100
Loop
Interrupt:
let b0 = hSerPtr - 1 'read the last received byte into b0
If b0 = $3B Then 'check if the last byte received is for RAD
'$3B received
high RAD_LED
End If
If b0 = $F0 Then 'check if the last byte received is for BMBO
'$F0 received
high BMBO_LED
End If
If b0 = $50 Then 'check if the last byte received is for MFL
'$50 received
high MFL_LED
End If
'prepare for next byte
hserinflag = 0
Return