I'm running a time sensitive loop on a 28x2. I'm using a pair of radios to communicate via hserin/out and have just two seconds to exchange information. The incoming information to the "base station" is of indeterminate length, generally multiples of 56 bytes but not always. I'm trying to conserve as much time as possible and thought I had a clever way of knowing when the receive burst was done and ready for processing. This, and several variations, was what I came up with as my solution.
pause 10
do
hserflag = 0
pause 20 ;tried various pause timings
loop until hserflag = 0
And it ALMOST worked. Unfortunately, no matter how I varied this loop, and even this one
pause 10
ptr = sp_flag_status
do
@ptr = hserptr
pause 10
@ptr = @ptr - hserptr
loop until @ptr = 0
It seems to drop bytes on the incoming stream. The dropped bytes seem random, not just being the first few or last few, for instance. Although in the first example, with certain timings, it would seem to drop just the last one or more bytes but I think that's just because I had a long enough initial pause to capture most of the stream before the loop.
I am guessing these loops interfere with the background receive in some way. I thought that background receive was independent of main program activity and hence my BRILLIANT solution(s). Although not sure, I have a feeling that accessing either the flag or the pointer causes a hiccup.
Nevertheless, I would really like to know the microsecond my byte stream receive is finished so I can make the most of the remaining time. An indiscriminate pause would have to accommodate the largest expected burst and will therefore waste time on most exchanges. My other alternative is to begin processing the receive buffer before the entire transmission is finished, but that complicates the programming and I'm also bumping at the limit of my code space.
So, I'd welcome ideas on ways to (simply) know when hserin has reached the end of my byte stream of indeterminate length.
I hope you enjoy my little challenges as much as I do ....(NOT.. This one cost a week of trying to track down the problem.)
John
pause 10
do
hserflag = 0
pause 20 ;tried various pause timings
loop until hserflag = 0
And it ALMOST worked. Unfortunately, no matter how I varied this loop, and even this one
pause 10
ptr = sp_flag_status
do
@ptr = hserptr
pause 10
@ptr = @ptr - hserptr
loop until @ptr = 0
It seems to drop bytes on the incoming stream. The dropped bytes seem random, not just being the first few or last few, for instance. Although in the first example, with certain timings, it would seem to drop just the last one or more bytes but I think that's just because I had a long enough initial pause to capture most of the stream before the loop.
I am guessing these loops interfere with the background receive in some way. I thought that background receive was independent of main program activity and hence my BRILLIANT solution(s). Although not sure, I have a feeling that accessing either the flag or the pointer causes a hiccup.
Nevertheless, I would really like to know the microsecond my byte stream receive is finished so I can make the most of the remaining time. An indiscriminate pause would have to accommodate the largest expected burst and will therefore waste time on most exchanges. My other alternative is to begin processing the receive buffer before the entire transmission is finished, but that complicates the programming and I'm also bumping at the limit of my code space.
So, I'd welcome ideas on ways to (simply) know when hserin has reached the end of my byte stream of indeterminate length.
I hope you enjoy my little challenges as much as I do ....(NOT.. This one cost a week of trying to track down the problem.)
John