One of the attractions of the PIC 18F26K22 is its ability to execute code at 64MHz with its internal clock. But I am unable to get either 32MHz or 64MHz despite enabling the PLL.
The simple test program to blink an LED at 1Hz is shown below.
'--------------------------------------------
DEFINE OSC 64 'Clock Speed: 64MHz
'Fuse setting to select the Internal Oscillator, to enable PLL and to enable Primary Clock
ASM
__CONFIG _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_ON_1H
ENDASM
OSCCON = %11110010 'Internal oscillator is set to 16MHz
OSCTUNE = %11000000 'HFINTOSC selected; PLL enabled; Factory calibrated frequency
ADCON0.0 = 0 'Disable ADC
ANSELA = 0
ANSELB = 0
ANSELC = 0
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 use PBPro 2.60C to compile and PICkit2 to program. There are no issues in compiling this code and programming a 18F26K22. But the code runs at one fourth the speed. 'Pause 500' statement produces a 2 second delay. I face the same problem if I want to run it at 32MHz (4 x 8MHz). In other words, it is as if the PLL does not get turned on. After compiling, the hex file opened in MeLabs programmer shows the status of the PLL as Enabled. If I change the first line of the code to DEFINE OSC 16, everything works fine at 16MHz; enabling or disabling the PLL in the code does not make any difference.
I have gone through the Oscillator section of the data sheet several times and I think I am doing everything required, but the PIC refuses to run at 64MHz speed. I will highly appreciate any help/suggestions to solve the problem.
Regards,
Bala
Bookmarks