subroutine with hserin


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Default subroutine with hserin

    Hi!

    My main program calls a subroutine.

    I wonder if the subroutine "ricezione" do not have the answer jumps on "accensione" then exiting from the first subroutine return of this command may be problems?

    Main:
    .........
    gosub ricezione
    .........
    goto Main

    ricezione:
    .........
    HSERIN 2000,accensione,[WAIT ("+CREG: "),Tm1,Tm2,Tm3]
    .........
    return

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    depending how "accensione" is made i guess... that snip above doesn't help us
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    depending how "accensione" is made i guess... that snip above doesn't help us


    accensione:
    pause 2000
    power=0
    led=1
    pause 2000
    power=1
    led=0
    Pause 30000
    gosub setup
    goto partenza

    What is the problem if I go out without a subroutine switch RETURN?

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Is it possible to see the whole program?

    Usually for each GOSUB, there's a RETURN

    Code:
    Start:
            Gosub Somewhere
            Gosub Elsewhere
            goto Start
            
    Somewhere:
            HSERIN 2000, SomeWhereElse,[DataXYZ]
            Return
            
    SomewhereElse:
            ToGGLE LED
            RETURN
            
    ElseWhere:
            LCDOUT $FE,1,"Are AZERTY Keyboards still on the market???"
            RETURN
    In Somewhere, if a timeout occure, it jump to SomewhereElse. This is basically a GOTO, BUT you need to use a RETURN to return to Start... or use a variant like...
    Code:
    Somewhere:
            HSERIN 2000, SomeWhereElse,[DataXYZ]
    
    SomewhereEnd:        
            Return
            
    SomewhereElse:
            ToGGLE LED
            Goto SomewhereEnd
    HTH
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Ok

    Thanks for the explanations

    Best regards

  6. #6
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post

    Code:
    Start:
            Gosub Somewhere
            Gosub Elsewhere
            goto Start
            
    Somewhere:
            HSERIN 2000, SomeWhereElse,[DataXYZ]
            Return
            
    SomewhereElse:
            ToGGLE LED
            RETURN
            
    ElseWhere:
            LCDOUT $FE,1,"Are AZERTY Keyboards still on the market???"
            RETURN

    Somewhere:
    HSERIN 2000, SomeWhereElse,[DataXYZ]

    SomewhereEnd:
    Return

    SomewhereElse:
    ToGGLE LED
    Goto SomewhereEnd
    [/code]

    HTH

    Then i can use two examples? The compiler detects if it is a routine principal or if it is a subroutine?

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Both example have to work. Once it hit a RETURN, it remove 1 from the stack level and jump one instruction bellow the last calling GOSUB.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Hserin with Instant Interrupts.
    By ronjodu in forum Serial
    Replies: 17
    Last Post: - 30th December 2014, 20:17
  2. timeout of Hserin, goto, gosub or both?
    By flipper_md in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th October 2009, 18:43
  3. 16F877a Interupt driven Hserin
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd November 2006, 00:38
  4. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 12:25
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 15:42

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