Re: Making a menu selection
Quote:
Originally Posted by
lerameur
Hi,
I am trying to make a menu selection SUB that will not exit until select button is pressed. I am using the PIC18F4550
Code:
Selection var PortC.6
Next1 var PortC.7
'/////////////////////////////////////
'/////// GetModeOfOperation ////////
'/////////////////////////////////////
GetModeOfOperation:
Lookup Op_Mode, [55,65],Operation_Mode
Select Case Operation_Mode
Case 55
lcdout $FE,1, " Charger Mode "
Case 65
lcdout $FE,1, " Recycle Mode"
End Select
lcdout $FE,$C0, "Next or Select"
pause 200
if Selection=1 then return
if Next1=1 then Op_Mode = Op_Mode + 1
if Op_Mode > 1 then Op_Mode = 0
Gosub GetModeOfOperation
Return
The problem, is that my sub routine exits (return) after 4 seconds while nothing has been pressed.
I just learned today that in th 18's you can overflow the stack. I don't really know the what happens when you do, but I suspect a "reset" maybe. Anyhow, I think the gosub needs to be a goto. otherwise you just keep calling itself without a return. everytime it saves PC to the stack, but never reads it back.
Re: Making a menu selection
ok wow work great now, thank you
K
Re: Making a menu selection
This should help you.
Quote:
Originally Posted by
lerameur
a menu selection SUB that will not exit until select button is pressed.
Code:
Selection var PortC.6
Next1 var PortC.7
'/////////////////////////////////////
'/////// GetModeOfOperation ////////
'/////////////////////////////////////
GetModeOfOperation:
while Selection = 0 ' exit when selection becomes 1
Lookup Op_Mode, [55,65],Operation_Mode
Select Case Operation_Mode
Case 55
lcdout $FE,1, " Charger Mode "
Case 65
lcdout $FE,1, " Recycle Mode"
End Select
lcdout $FE,$C0, "Next or Select"
pause 200
if Next1=1 then Op_Mode = Op_Mode + 1
if Op_Mode > 1 then Op_Mode = 0
wend
Return