PIC 16F676 no digital output on PORTA4 and PORTA5

Discussion in 'Embedded Systems and Microcontrollers' started by Bob Wya, Sep 11, 2007.

  1. Bob Wya

    Thread Starter New Member

    Nov 9, 2005
    5
    0
    Hi all,

    I am trying to knock together a 'knight-rider' display using software PWM of 9 L.E.D.s using outputs from a PIC16F676 (all outputs have a 680 ohm resister on them in series with L.E.D.).

    I am just using MPLAB to software simulate and programming using an Embedinc programmer (ISCP connection).

    The .asm code works perfectly when I software simulate it on a PC. Ports RA4 and RA5 are enabled appropriately.

    In practice the circuit works great but outputs RA4 and RA5 don't do anything (i.e. stay at ground potential). I have the IC set to use the internal clock and to not output the clock (which would come out on RA4 or RA5 I believe). Even if I hard code a port RA4 and RA5 enable in the code ... still no joy so I guess it's something to do with the shared nature of the outputs (perhaps ??)

    The comparator is turned off, all port A as digital outputs (ANSEL and TRISA both cleared) - obviously I don't use RA3.

    Any suggestions what I could be doing wrong?? My configuration code is in the box below...

    Any help would be appreciated!! (From a complete newbie!!)

    Thanks

    Rob


    Code ( (Unknown Language)):
    1.  
    2.         ORG    0
    3.         GOTO    RESET
    4.        
    5.         ORG    4
    6. INTERRUPT
    7.  
    8.   ....
    9.  
    10. RESET
    11.         CLRWDT
    12.         BSF     STATUS,RP0         ; Bank 1
    13.         CLRF    WPUA
    14.         CLRF    IOCA
    15.         MOVLW     B'10000111'
    16.         MOVWF     OPTION_REG
    17.         MOVLW    B'00010000'
    18.         MOVWF    ADCON1
    19.         MOVLW    B'00000000'
    20.         MOVWF    ANSEL
    21.         MOVLW    B'00000000'
    22.         MOVWF    TRISA
    23.         MOVLW    B'00000000'
    24.         MOVWF    TRISC
    25.         BSF        PIE1,TMR1IE
    26.         BCF     STATUS,RP0        ; Bank 0
    27.         BCF        ADCON0,ADON
    28.         CLRF    PORTA_0002
    29.         CLRF    PORTC_0002
    30.         CLRF    PORTA_001
    31.         CLRF    PORTC_001
    32.         CLRF    PORTA_005
    33.         CLRF    PORTC_005
    34.         CLRF    PORTA_025
    35.         CLRF    PORTC_025
    36.         CLRF    PORTA_100
    37.         CLRF    PORTC_100
    38.         CLRF    BIT_MASK+0
    39.         CLRF    BIT_MASK+1
    40.         CLRF    BIT_MASK+2
    41.         BSF        BIT_MASK+1,0
    42.         CLRF    CONTROL_FLAG
    43.         BSF        CONTROL_FLAG,0
    44.         CLRF    DELAY_TIMER
    45.         INCF    DELAY_TIMER
    46.         MOVLW    B'00000111'
    47.         MOVWF    CMCON
    48.         ; Setup timer 1 and start
    49.         CLRF    TMR1L
    50.         CLRF    TMR1H
    51.         MOVLW    B'00111001'
    52.         MOVWF    T1CON
    53.         CLRF    INTCON
    54.         BSF        INTCON,PEIE
    55.         BSF        INTCON,GIE
    56.         CALL    INTERRUPT
    57. MAIN_LOOP
    58.  
    59. ....
    60.  
    61.  
     
  2. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Looks like you are setting T1OSCEN which automagically sets the TRISA4 & TRISA5 and clears RA4 & RA5.
     
  3. Bob Wya

    Thread Starter New Member

    Nov 9, 2005
    5
    0
    Hi

    Thanks I still don't really understand what that bit does ... hence why I didn't spot my deliberate mistake!!


    I'll have a go with it cleared today!!


    Thanks again

    Rob
     
  4. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    It turns on the LP Oscillator and clocks T1 with it when you are using the internal oscillator as the system clock. It'll work during sleep also so you can use it as low power counter/timer to wake up from.
     
  5. Bob Wya

    Thread Starter New Member

    Nov 9, 2005
    5
    0
    Wicked!! problem solved... Thanks for all your help!!

    Bob Wya

    PS Does LP Oscillator mean Low Power oscillator (just for sleep state)?? Sorry since I am doing all mains power projects I haven't really needed to look into any power saving info!!
     
  6. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Yes it it is the low power oscillator. It is not just for sleep state but can be the system clock also. It is designed to run during sleep states so you can keep a running counter. Often in low power apps you just need to periodically wake up and do some function (quickly) and then go back to sleep.
     
Loading...