Menu

Macro Infinite Loop

Mikorians
2017-08-02
2018-01-21
  • Mikorians

    Mikorians - 2017-08-02

    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

     
  • William Roth

    William Roth - 2017-08-03

    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.

     
  • Mikorians

    Mikorians - 2017-08-03

    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 :)

     

Log in to post a comment.