return for GOSUB not working


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default return for GOSUB not working

    Hi,

    Running into a little problem. When My Gosub functions ends, it does not return. Instead it stalls there and Both buttons do not work.. I have RB2 for Select and RB3 for Next (buttons) when it finished the minutes, the LCD freezes and nothing happens... some have a clue??

    Code:
    '/////////////////////////////////////   
    '///////////     SetProgrammerTime  ////////////
    '/////////////////////////////////////
    SetProgrammerTime:
     pause 400
     
         while Selection = 0           ' exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                                    
                lcdout $FE,1,  "Set Time?"
                lcdout $FE,$C0, "Next or Select"
                pause 300
                    
            if NextOption=1 then return    'button NextOption,
        
        wend
    
    ThisYear = 2011 
    Pause 500  
         while Selection = 0           ' exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                        
                lcdout $FE,1,  "Set Year"
                lcdout $FE,$C0, dec4 ThisYear
                pause 300
                    
            if NextOption=1 then ThisYear = ThisYear +1    'Button on NextOption (PORTB.3)
              
        wend
    
    
    ThisMonth= 1
    Pause 500    
     while Selection = 0           'exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                        
                lcdout $FE,1,  "Set Month"
                lcdout $FE,$C0, dec2 ThisMonth
                pause 300
                    
            if NextOption=1 then ThisMonth=ThisMonth +1 : pause 50
                if  ThisMonth > 12 then ThisMonth = 1
               
        wend
    
    
    ThisDay= 1
    Pause 500
         while Selection = 0           ' exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                        
                lcdout $FE,1,  "Set Day"
                lcdout $FE,$C0, dec2 ThisDay
                pause 300
                    
            if NextOption=1 then ThisDay=ThisDay +1
                if  ThisDay > 31 then ThisDay = 1
           wend
    
    
    ThisHour= 0
    Pause 500
         while Selection = 0           ' exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                        
                lcdout $FE,1,  "Set Hour"
                lcdout $FE,$C0, dec2 ThisHour
                pause 300
                    
            if NextOption=1 then ThisHour=ThisHour +1
                if  ThisHour > 59 then ThisHour = 1
    
        wend
    
    
    ThisMin= 0
    Pause 500
         while Selection = 0           ' exit when selection becomes 1   Selection is a buton and next1 is another button on the main panel
                        
                lcdout $FE,1,  "Set Min"
                lcdout $FE,$C0, dec2 ThisMin
                pause 300
                    
            if NextOption=1 then ThisMin=ThisMin +1
                if  ThisMin > 59 then ThisMin = 0
    
        wend
        
        Pause 300
                                       
    'I2CWRITE SDApin,SCLpin,$D0,$00,[$00,ThisMin,ThisHour,$6,ThisDay,ThisMonth,ThisYear,$00] ' Writes to DS1307 
     'Pause 30
     
     return

  2. #2
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    637


    Did you find this post helpful? Yes | No

    Default Re: return for GOSUB not working

    Quote Originally Posted by lerameur View Post
    Hi,

    Running into a little problem. When My Gosub functions ends, it does not return. Instead it stalls there and Both buttons do not work.. I have RB2 for Select and RB3 for Next (buttons) when it finished the minutes, the LCD freezes and nothing happens... some have a clue??
    Hmmm, I don't see anything wrong in your SetProgrammerTime sub-routine . The problem might be in your main code after the line GOSUB SetProgrammerTime. See how far the code runs before it freezes.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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