PDA

View Full Version : PIC18F14K22 and PLL (4 x Phase Lock Loop)



Momboz
- 31st October 2010, 20:32
Hi

I am trying to run a PIC18F14K22 in PLL mode with internal oscillator and PLL (i.e. frequency x 4). The internal clock should be 64'000'000 MHz. Here is my sample code:



asm
__CONFIG _CONFIG1H, _FOSC_IRC_1H & _PLLEN_ON_1H & _PCLKEN_ON_1H & _FCMEN_ON_1H & _IESO_ON_1H
__CONFIG _CONFIG2L, _BOREN_OFF_2L
__CONFIG _CONFIG2H, _WDTEN_OFF_2H & _WDTPS_128_2H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_ON_4L & _XINST_OFF_4L
__CONFIG _CONFIG7L, _EBTR0_ON_7L
endasm

TRISA = 0

main:
asm
BSF PORTA, 0
BCF PORTA, 0
BSF PORTA, 0
BCF PORTA, 0
BSF PORTA, 0
BCF PORTA, 0
endasm

goto main

end



This peace of code is assumed to deliver 3 pulses again and again. I got on my scope 3 pulses at 4.20 us duration and I was expecting about 15 ns each pulse duraton since the BSF and BCF instructions last one clock cycle and that cycle should last about 15 ns.

See annexed image for result details on scope.

Any advice to me?

Many thanks in advance.

ScaleRobotics
- 31st October 2010, 20:46
Did you set the OSCCON register? Otherwise it will default to 1 mhz (x4 pll) = 4 mhz.

Momboz
- 31st October 2010, 20:58
Did you set the OSCCON register? Otherwise it will default to 1 mhz (x4 pll) = 4 mhz.


I didn't do that setting before. I did it now and everything works fine now.

Thank you so much for your help.