I'm writing my code for dual thermometer and discovered that the GCBASIC capable to compile the code nicely but it doesn't run when I include both subroutines that contain DO UNTIL command.
The skeleton of my program is:
#chip config bla bla bla...
mainloop:
Select Case variable
Case 1
Goto Sub1
Case 2
Goto Sub2
End Select
Goto mainloop
Sub Sub1
InitSub1 = False
Do UNTIL InitSub1 = True
Bla bla bla
Conditions
InitSub1 = True
Loop
End Sub
Sub Sub2
InitSub2 = False
Do UNTIL InitSub2 = True
Bla bla bla
Conditions
InitSub2 = True
Loop
End Sub
After detail investigation, the conclusion that I can make is that most likely this is a bug of QCBASIC. The reason is, if we only include either Goto Sub1 or Goto Sub2 in the main loop (i.e. comment out Goto Sub1 or Goto Sub2, the PIC will work just fine. When the main loop included both routines, the PIC is simply not running (hang I believe). I've verified the running status of PIC using LCD and also blinking LED in case you are in doubt.
Would appreciate if you would investigate in detail.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Found this in the help file:
Note that the WHILE or UNTIL and the condition can only be specified once, or not at all. If they are not specified, then the code will repeat endlessly.
So it is caused by the limitation of GCBASIC itself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your code should work, I compiled it (after changing both Gotos to Gosubs) and the assembly looks fine. Could you please email me the entire source file, so I can check it? It's possible that something in one sub is interfering with something in the other - all variables are global in GCBASIC.
You can have multiple loops in the program, each with either a while or an until. The only thing you can't do is something like this:
Do while ...
something
Loop while ...
That is, either put something after Do, or put something after Loop, or don't put anything - just don't put something after Do and after Loop in the same loop.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi admin,
I'm writing my code for dual thermometer and discovered that the GCBASIC capable to compile the code nicely but it doesn't run when I include both subroutines that contain DO UNTIL command.
The skeleton of my program is:
#chip config bla bla bla...
mainloop:
Select Case variable
Case 1
Goto Sub1
Case 2
Goto Sub2
End Select
Goto mainloop
Sub Sub1
InitSub1 = False
Do UNTIL InitSub1 = True
Bla bla bla
Conditions
InitSub1 = True
Loop
End Sub
Sub Sub2
InitSub2 = False
Do UNTIL InitSub2 = True
Bla bla bla
Conditions
InitSub2 = True
Loop
End Sub
After detail investigation, the conclusion that I can make is that most likely this is a bug of QCBASIC. The reason is, if we only include either Goto Sub1 or Goto Sub2 in the main loop (i.e. comment out Goto Sub1 or Goto Sub2, the PIC will work just fine. When the main loop included both routines, the PIC is simply not running (hang I believe). I've verified the running status of PIC using LCD and also blinking LED in case you are in doubt.
Would appreciate if you would investigate in detail.
Correction, the mainloop should be:
mainloop:
Select Case variable
Case 1
GoSub Sub1
Case 2
Goto Sub2
End Select
GoSub mainloop
Found this in the help file:
Note that the WHILE or UNTIL and the condition can only be specified once, or not at all. If they are not specified, then the code will repeat endlessly.
So it is caused by the limitation of GCBASIC itself.
Your code should work, I compiled it (after changing both Gotos to Gosubs) and the assembly looks fine. Could you please email me the entire source file, so I can check it? It's possible that something in one sub is interfering with something in the other - all variables are global in GCBASIC.
You can have multiple loops in the program, each with either a while or an until. The only thing you can't do is something like this:
Do while ...
something
Loop while ...
That is, either put something after Do, or put something after Loop, or don't put anything - just don't put something after Do and after Loop in the same loop.