BS2 SERIN Question
tweek.3867
Posts: 7
I'm currently using two BS2's wirelessly communicating via two transceivers. I'm having one issue, though,
The receiving program has a SERIN nested in a for loop, somewhat like this:
start:
FOR i = 0 TO n
· FOR j = 0 TO n
····OTHER CODE GOES HERE
··· SERIN SI, Baud, [noparse][[/noparse]serBinCheck]
··· IF serBinCheck = %1111 THEN·GoHere
··· PAUSE 16
· NEXT
NEXT
GOTO start
The issue I'm having, though, is that there is only occasionally something being sent. Basically, it is running something and then there is a natural pause in the loop already, and during that pause I want the SERIN to run. However, if nothing is being sent for it to receive at the time, then the SERIN function causes it to stall. So what I figure is the logical thing to do is add a timeout function (length 16) and then take out the PAUSE 16, so that the·SERIN will automatically do the PAUSE 16, or if something is received move off to the new location in the code. This is where my problem happens.
In order to add a timeout length, you have to add a GOTO location, in case the actual timeout occurs, but I just want it to continue the loop. I tried a simple work around and added a GOTO label right after the SERIN statement, like this:
··· SERIN SI, Baud, 16, continue, [noparse][[/noparse]serBinCheck]
··· continue:
··· IF serBinCheck = %1111 THEN ResetReps
But in doing that, it essentially breaks out of the for loop and ends up at the GOTO start, repeating the loop endlessly, which is something that breaks the program. I was thinking about being kind of skeevy about it and rather than using a for loop, just relying on the GOTO statements and manually updating the i and j counter variables, but I feel like there has to be a better way.
Any ideas would be incredible. Thanks so much!
The receiving program has a SERIN nested in a for loop, somewhat like this:
start:
FOR i = 0 TO n
· FOR j = 0 TO n
····OTHER CODE GOES HERE
··· SERIN SI, Baud, [noparse][[/noparse]serBinCheck]
··· IF serBinCheck = %1111 THEN·GoHere
··· PAUSE 16
· NEXT
NEXT
GOTO start
The issue I'm having, though, is that there is only occasionally something being sent. Basically, it is running something and then there is a natural pause in the loop already, and during that pause I want the SERIN to run. However, if nothing is being sent for it to receive at the time, then the SERIN function causes it to stall. So what I figure is the logical thing to do is add a timeout function (length 16) and then take out the PAUSE 16, so that the·SERIN will automatically do the PAUSE 16, or if something is received move off to the new location in the code. This is where my problem happens.
In order to add a timeout length, you have to add a GOTO location, in case the actual timeout occurs, but I just want it to continue the loop. I tried a simple work around and added a GOTO label right after the SERIN statement, like this:
··· SERIN SI, Baud, 16, continue, [noparse][[/noparse]serBinCheck]
··· continue:
··· IF serBinCheck = %1111 THEN ResetReps
But in doing that, it essentially breaks out of the for loop and ends up at the GOTO start, repeating the loop endlessly, which is something that breaks the program. I was thinking about being kind of skeevy about it and rather than using a for loop, just relying on the GOTO statements and manually updating the i and j counter variables, but I feel like there has to be a better way.
Any ideas would be incredible. Thanks so much!
Comments
·SERIN SI, Baud,300,continue, [noparse][[/noparse]serBinCheck]
··· IF serBinCheck = %1111 THEN·GoHere
···continue:
Jeff T.
I probably just misjudged the timing, though, which is what made me think it was breaking out of the loop. I have a debug statement running prior to the loop starts so I know when it repeats and it was spitting out so fast I just assumed it was exiting the loop entirely, but you're very right in that 16mSec is a very small amount of time so that was probably fine.
Thanks for the advice!
Jeff T.
SERIN SI, Baud,300,continue, [noparse][[/noparse]serBinCheck]
IF serBinCheck = %1111 THEN GoHere
NEXT
continue:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Manetheren