PDA

View Full Version : Repeat .... UNTIL code



SKOLS1
- 21st April 2012, 21:49
Why this code doesn't work?I pull up Termos(PORTB.6) and If Termos = 0 then the relay and on the LCD must be shown those commands.When Termos is HIGH,then back to the main program(With Return).
CHECK:
Repeat
LOW Relay : LCDOUT $FE, 1: LCDOUT $FE, 1, " Alarm vklucen " : LCDOUT $FE, $c0, $05 : LCDOUT $FE, $C0+13,"OFF"
High Buzzer
LOW BICG
HIGH BICR
Pause 350
Low Buzzer
Until Termos = 0
Return

mackrackit
- 21st April 2012, 22:08
RETURN is used with GOSUB.
You will want GOTO CHECK

From the manual:

RETURN

Return from subroutine. RETURN resumes execution at the statement following the GOSUB which called the subroutine.

Gosub sub1 ' Go to subroutine labeled sub1
...
sub1: Serout 0,N2400,[“Lunch”] ' Send “Lunch” out Pin0 serially
RETURN ' Return to main program after Gosub

SKOLS1
- 21st April 2012, 22:30
and RETURN i should use,too?

mackrackit
- 21st April 2012, 22:59
Maybe that is not your whole code? But basically code should be structured something like:


MAIN:
'Do stuff
GOSUB SubCode 'Jumps to label SubCode
GOTO SomeCodeBlock
GOTO MAIN ' Goes back to MAIN label


SomeCodeBlock:
'Do Stuff
GOTO MAIN ' Goes back to MAIN label

SubCode:
'Do Stuff
RETURN ' Takes you back to the line after the GOSUB

aratti
- 22nd April 2012, 00:11
You should read the Termos value within the Repeat/Until loop, or you will never exit from the loop.

Cheers

Al.