I don’t know if you are sending serial in the interrupt or main program, and assumed it’s in the main program.
Having said that, I can’t think of a reason you need to do serial in the interrupt, but there might be a reason.
I’m saying sending a slab like that will ruin the illusion of doing things simultaneously like programs do,
and that there’s no recovering from it.
Think if you did this:
Code:
hserout[a,b,c,d,e,f,i,j]
Then later you wanted the same program to also receive a serial command that could arrive at any time. You’re screwed.
For example if a GPS sent it’s data sentence to your chip while in the middle of your program sending that eight byte slab.
But you can easily have a fully duplex serial port with PBP HSEROUT.
You can be sending the eight byte slab at the same time as receiving something,
and once implemented you barely have to think about it.
Code:
atoj var byte[8]
rxbuffer[8]
index var byte
rxindex var byte
serbuff var byte
rxbuff var byte
mainloop:
‘ your program
if index > 7 then ‘ data packet was sent, so send another.
index = 0’
endif
if rxbuff = enterkey then ‘ check for end of incoming command
rxindex = 0
‘do something with received command
endif
if index < 8 then
serbuff = atoj[index]
hserout[serbuff]
index = index + 1
endif
if rxindex < 8 then
hserin[rxbuff,shortesttimeout,donelabel]
donelabel:
rxbuffer[rxindex] = rxbuff
rxindex = rxindex + 1
endif
goto mainloop
Bookmarks