Can't Toggle PORTC.4 on PIC18F13K22


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164

    Default Can't Toggle PORTC.4 on PIC18F13K22

    I'm working my way around a new PIC, the 18F13K22 at a smokin' 64 MHz using the internal osc and PLL. Finally got that working but for the life of me, I can't get pin 7 (RC3) to toggle. The following code toggles pin 8 (RC4) but not pin 7:

    Code:
    #config    CONFIG FOSC = IRC        ;Internal RC oscillator
        CONFIG PLLEN = ON        ;Oscillator multiplied by 4
        CONFIG IESO = OFF        ;Oscillator Switchover mode disabled
        CONFIG BOREN = OFF        ;Brown-out Reset disabled in hardware and software
        CONFIG WDTEN = OFF        ;WDT is controlled by SWDTEN bit of the WDTCON register
        CONFIG WDTPS = 32768        ;1:32768
        CONFIG MCLRE = ON        ;MCLR pin enabled, RA3 input pin disabled
        CONFIG XINST = ON        ;Instruction set extension and Indexed Addressing mode enabled
    #ENDCONFIG
    
    DEFINE OSC 64
    
    ANSEL = 0
    ANSELH = 0
    
    LATC  = %11000100
    TRISC = %00000000
    LATB  = %01000000
    TRISB = %00110000
    LATA  = %00000000
    TRISA = %00000111
    
    'Set internal osc to 16 MHz, PLL enabled
    OSCCON.6 = 1
    OSCCON.5 = 1
    OSCCON.4 = 1
    OSCTUNE.6 = %1
    
    pause 500
    
    Main:
        LATC.4 = 1
        LATC.3 = 1
        pause 500
        LATC.4 = 0
        LATC.3 = 0
        pause 500
    goto Main
    Am I missing something silly and obvious?

    Best Regards,
    Paul
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Can't Toggle PORTC.4 on PIC18F13K22

    Try it with ...

    CONFIG XINST = OFF
    CONFIG LVP = OFF
    DT

  3. #3
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: Can't Toggle PORTC.4 on PIC18F13K22

    Wow, thanks Darrel! How come that made it work?
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Can't Toggle PORTC.4 on PIC18F13K22

    On that chip, RC3 is also the PGM pin for Low Voltage Programming (LVP).
    When LVP is enabled, you can't use that pin for anything else.

    And you should ALWAYS disable the Extended Instruction Set (XINST).
    PBP will not function properly when XINST is enabled.
    DT

  5. #5
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: Can't Toggle PORTC.4 on PIC18F13K22

    Thank you for taking the time to explain, it is much appreciated.

    Best Regards,
    Paul
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

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