LED turns off when jumping to a routine


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Posts
    42

    Default LED turns off when jumping to a routine

    I have a funny issue I have been dealing with for some time and can't figure it out.

    I am using a 16F1829 and have the LED on porta.5

    During my startup routine, I have porta.5 setup for digital, no pull ups, the latch register is set to low and the tris register is set for input.

    When I turn on a feature on my project, I turn the LED on by flipping the tris register to an output. This lets the customer know that the feature is on.

    Now when they press another button, the code does a jump (gosub) to a routine. When this happens, it turns the LED off.

    For the life of me, I can't understand why.

    Here is my startup configuration
    Code:
    DEFINE OSC 32
    PORTA = 0
    PORTB = 0
    PORTC = 0
    '***************************************************************
    '*****************CONFIGURATION WORDS IN INCLUDE****************
    '***************************************************************
    
    '__CONFIG _CONFIG1, _FCMEN_ON, _IESO_OFF, _CLKOUTEN_OFF, _BOREN_OFF, _CPD_OFF, _CP_OFF, _MCLRE_ON, _PWRTE_OFF, _WDTE_OFF, _FOSC_INTOSC
    '__CONFIG _CONFIG2, _LVP_ON, _BORV_19, _STVREN_OFF, _PLLEN_ON, _WRT_OFF
    
    '***************************************************************
    '********************SET STANDARD REGISTERS*********************
    '***************************************************************
    
    ''''''OSCILLATOR REGISTERS'''''
    OSCCON = %11110000
    OSCTUNE = %011111
    
    ''''''PORT REGISTERS'''''''''''
    OPTION_REG = %00000000
    ADCON0 = %00000000
    ADCON1 = %00000000
    DACCON0 = %00000000
    DACCON1 = %00000000
    SRCON0 = %00000000
    SRCON1 = %00000000
    INTCON = %00000000
    FVRCON = %00000000
    MDCON = %00000000
    BORCON = %00000000
    SRCON0 = %00000000
    SRCON1 = %00000000
    PIE1 = %00000000
    PIE2 = %00000000
    PIE3 = %00000000
    PIE4 = %00000000
    
    
    CM1CON0 = %00000000
    CM1CON1 = %00000000
    CM2CON0 = %00000000
    CM2CON1 = %00000000
    
    '***************************************************************
    '********************SET PORTS**********************************
    '***************************************************************
    
    ''''''PORTA SETUP''''''''
    ANSELA = %00000000
    WPUA = %11001010
    INLVLA = %00000000
    LATA = %00010000
    TRISA = %11111111
    
    ''''''PORTB SETUP''''''''
    ANSELB = %00000000
    WPUB = %11001111
    INLVLB = %01110000
    LATB = %00000000
    TRISB = %11111111
    
    ''''''PORTC SETUP''''''''
    ANSELC = %00000000
    WPUC = %11111001
    INLVLC = %00000000
    LATC = %00000110
    TRISC = %11111111
    Last edited by Archangel; - 18th February 2014 at 19:01. Reason: code tags

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    that was the jumped to routine that was interesting ...

    just to see which commands you use for it.

    BTW ... is there any special reason for that ???
    Code:
    OSCTUNE = %011111
    Alain
    Last edited by Acetronics2; - 18th February 2014 at 16:44.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2007
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    That sets the oscillator tuning register to maximum frequency however, after seeing it, it looks as though I am missing a bit.

    I also don't understand the other question you asked

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    I was just asking for the listing of the routine that "Bugs" ...

    no more !
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    Now when they press another button, the code does a jump (gosub) to a routine. When this happens, it turns the LED off.
    Seeing the offending code would certainly help, which is what Alian is trying to say.

    The program is probably starting over from the top for one reason or another, resetting the TRISA to 255 (all inputs), disabling the output drivers. My guess is that you're missing a RETURN at the end of the subroutine to which you jump with a GOSUB.

    /Henrik.

  6. #6
    Join Date
    Nov 2007
    Posts
    42


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    It returns to the loop it came from. I will put up the routine causing the issue when I get back to my office.

  7. #7
    alopor's Avatar
    alopor Guest


    Did you find this post helpful? Yes | No

    Default Re: LED turns off when jumping to a routine

    It returns to the loop it came from.

Similar Threads

  1. programming jumping game
    By bokken in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th February 2012, 06:40
  2. jumping out of subroutine with goto
    By helloo in forum General
    Replies: 4
    Last Post: - 3rd January 2012, 10:37
  3. OWIN not jumping to label
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2011, 15:30
  4. PIC16F84A Tachometer LED routine
    By ThaSanta in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 24th July 2009, 02:58
  5. Pot reading jumping like crazy!!!
    By champion in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 20th November 2006, 21:24

Members who have read this thread : 0

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