GCBasic.exe compiles to Main and HANGS
because of the GOTO. Guess I must rephrase my If's to While or something...
Macro ReadSonarA0
Gosub StartOurClock
Dir PORTC.0 Out.....
SonarTimeA0:
Timer16Bit
If PORTC.0=1 Then
If Tmp2<SoTimO then
Goto SonarTimeA0
End If
End If
SoA1=Tmp2: SoA2=Tmp1
Gosub SonarPause
End Macro
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You cannot place a label (SonarTimeA0) inside of a Macro. This is causing the hang. So yes, eliminate the Label and the Goto and use a loop instead.
Neither can you properly test the state of PORTC.0 with "IF PortC.0 = 1" when the Pin is set as an output. If you want to test if C.0 has been turned on, then test LATC.0 instead of PortC.0.
Try to structure your code without using goto / label.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can understand why.
It's merely that it might've been more useful to US as a sort of
multi-line #Define.
(The pin dir was an input by the end of a very long line)
Normally we are quite tidy in our coding and conform to
OOP practices, but the limited stack on these inexpensive
mass purchased PICs nearly DEMANDS violating those
practices. Plus with Or/And being iffy, we have to bust 'em up.
(So we're glad Goto's there :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GCBasic.exe compiles to Main and HANGS
because of the GOTO. Guess I must rephrase my If's to While or something...
Macro ReadSonarA0
Gosub StartOurClock
Dir PORTC.0 Out.....
SonarTimeA0:
Timer16Bit
If PORTC.0=1 Then
If Tmp2<SoTimO then
Goto SonarTimeA0
End If
End If
SoA1=Tmp2: SoA2=Tmp1
Gosub SonarPause
End Macro
You cannot place a label (SonarTimeA0) inside of a Macro. This is causing the hang. So yes, eliminate the Label and the Goto and use a loop instead.
Neither can you properly test the state of PORTC.0 with "IF PortC.0 = 1" when the Pin is set as an output. If you want to test if C.0 has been turned on, then test LATC.0 instead of PortC.0.
Try to structure your code without using goto / label.
I can understand why.
It's merely that it might've been more useful to US as a sort of
multi-line #Define.
(The pin dir was an input by the end of a very long line)
Normally we are quite tidy in our coding and conform to
OOP practices, but the limited stack on these inexpensive
mass purchased PICs nearly DEMANDS violating those
practices. Plus with Or/And being iffy, we have to bust 'em up.
(So we're glad Goto's there :)