PIC18f25k22 help with OSC configs


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    70

    Default PIC18f25k22 help with OSC configs

    This is a case of trying too many new things at once. I'm using a PIC18f25k22 (a new device for me) with a standalone, 3-pin 20 Mhz oscillator (also new to me - see photo), and PBP 3 (new to everyone). Right now I'm just starting with a blinky program. I can flash an LED no problem using the internal oscillator, but when I try the external oscillator, the led flashes way too slow--about 20 times too slow to be more precise. If I change the DEFINE OSC statement from 20 to 4 the flashing speeds up, but it is still too slow. It is as if the oscillator is actually working at 1 Mhz instead of 20.
    Name:  temp_PIC18f25k22.jpg
Views: 1222
Size:  174.3 KB

    Here is what works (internal oscillator):

    Code:
    asm   
          __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H
          __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_INTMCLR_3H
          __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    endasm
    
    
    OSCCON  = 110000;                         ' 16mHz 
    
    
    DEFINE OSC 16
    
    
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0    
    
    
    TRISA = 0
    TRISB = 0
    TRISC = 0
    
    
    PORTA = 0
    PORTB = 0
    PORTC = 0
    
    
    FLASHLOOP:
    HIGH PORTB.4
    pause 500
    LOW PORTB.4
    PAUSE 500
    GOTO FLASHLOOP
    
    
    eND
    And here is what works way too slow:

    Code:
    asm   
          __CONFIG    _CONFIG1H, _FOSC_XT_1H
          __CONFIG    _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_INTMCLR_3H
          __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    endasm
    
    
    DEFINE OSC 20
    
    
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0     
    
    
    TRISA = 0
    TRISB = 0
    TRISC = 0
    
    
    PORTA = 0
    PORTB = 0
    PORTC = 0
    
    
    FLASHLOOP:
    HIGH PORTB.4
    pause 500
    LOW PORTB.4
    PAUSE 500
    GOTO FLASHLOOP
    
    
    eND
    I'm hopeful that someone will see an obvious error. I've been playing around with configuration settings and datasheets, but I am far from exhausting all possible options.

  2. #2
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: PIC18f25k22 help with OSC configs

    Nevermind. Figured it out 5 minutes later. I needed to specify a high speed, high power oscillator and I had to turn off the clock multiplier thingy. In other words:


    _CONFIG _CONFIG1H, _FOSC_HSHP_1H & _PLLCFG_OFF_1H

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: PIC18f25k22 help with OSC configs

    Brid0030,
    I can’t see the connection with your EXT OSC CONFIG’S but there is a note in the OSC module section of the data sheet that says the default output freq of HFINTOSC is 1 Mhz. Did you include in your post all of your EXT OSC code?

    Wayne
    Last edited by MOUNTAIN747; - 6th February 2012 at 23:12. Reason: OOPS too late!

  4. #4
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default Re: PIC18f25k22 help with OSC configs

    Not sure what you are getting at, Wayne. Yes, all the code is there. The 1 Mhz default condition might explain why the PIC seemed to operate at 1 Mhz when I specified the wrong OSC configuration (XT and not HFHP).

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PIC18f25k22 help with OSC configs

    Read his edit where he says oops!

    Robert

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts