18F26K22 - Unable to get 64MHz Internal clock speed


Results 1 to 4 of 4

Threaded View

  1. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,161


    Did you find this post helpful? Yes | No

    Default Re: 18F26K22 - Unable to get 64MHz Internal clock speed

    I also use PBP 2.60C on a 18F24K22 (same family of PICs). Looks like you're missing one register, try this:

    Code:
    '   PIC     18F24K22    int osc 64MHz
    
    asm
     __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_OFF_1H
     __CONFIG    _CONFIG2L, _PWRTEN_ON_2L & _BOREN_SBORDIS_2L & _BORV_285_2L
     __CONFIG    _CONFIG2H, _WDTEN_OFF_2H
     __CONFIG    _CONFIG3H, _CCP2MX_PORTC1_3H & _PBADEN_OFF_3H  & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTC0_3H & _MCLRE_EXTMCLR_3H
     __CONFIG    _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    endasm
    
    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    
    ' Define	LOADER_USED	1
    DEFINE OSC 64
    
    ;INCLUDE "AllDigital.pbp"
    ;DEFINE SHOWDIGITAL 1
    
    OSCCON  = %01110000                 ' I didn't need to set bit 7 of OSCCON for SLEEP
    OSCCON2 = %10000100
    OSCTUNE = %11000000
    
    ADCON0 = %00000000                  ' Disable ADC
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    
    ' Your code
    
    CM1CON0.7 = 0 'Disable comparator1
    CM2CON0.7 = 0 'Disable comparator2
    
    'Port direction
    TRISA = 0 'All are Outputs
    TRISB = 0 'All are Outputs 
    TRISC = 0 'All are Outputs
    
    START:
    
    PortC.3 = 1 : pause 500 'Turn the LED on and wait for half a second
    PortC.3 = 0 : pause 500 'Turn the LED off and wait for half a second
    
    GOTO START
    
    END
    I just noticed I didn't set the MFINTOSC Frequency Stable bit in OSCCON, don't know the impact of that. I'd start by adding OSCCON2 first, I know I put that there for a reason, just can't remember - I got this code running back in January.

    Robert
    Last edited by Demon; - 16th July 2014 at 12:51. Reason: Refining

Similar Threads

  1. Replies: 15
    Last Post: - 27th January 2012, 16:10
  2. Running led blink at 64mhz with 18f26k22.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th April 2011, 18:58
  3. How to set the internal CPU speed?
    By Ramius in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th April 2011, 20:04
  4. external clock / internal clock
    By grounded in forum General
    Replies: 4
    Last Post: - 31st May 2008, 17:44
  5. 16F628 Internal clock
    By srob in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th February 2007, 18:46

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