Repeat .... UNTIL code


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71

    Default Repeat .... UNTIL code

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Repeat .... UNTIL code

    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
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default Re: Repeat .... UNTIL code

    and RETURN i should use,too?

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Repeat .... UNTIL code

    Maybe that is not your whole code? But basically code should be structured something like:
    Code:
    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
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: Repeat .... UNTIL code

    You should read the Termos value within the Repeat/Until loop, or you will never exit from the loop.

    Cheers

    Al.
    All progress began with an idea

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts