LED turns off when jumping to a routine


Results 1 to 9 of 9

Threaded 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

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