pic18f2620 internal oscillator
xorcise said:
The solution is to use the PRIMARY OSC block by setting OSCCON <1:0> to 00.
FOSC<4:0> settings at 1001 or 1000, and set the PLLEN bit in OSCTUNE<6>.
I tested the following mikroBasic code on a 18F4525 and delays based on 32MHz... it works!
hi, xorcise
I tested it (OSCCON <1:0> to 00) on my PIC18F2620, but no result, also at 8MHz
Added after 5 minutes:
Mike said:
I've used INTOSC and PLL too (for 32 MHz). Works fine.
hi, Mike, K8LH
I tested with your code, and my PIC continue at 8MHz
You tested in a PIC18F2620?
If yes, what is the revision?
Added after 8 minutes:
Mike said:
I've used INTOSC and PLL too (for 32 MHz). Works fine.
Here's an Assembler example;
Code:
(...)
bcf OSCTUNE,PLLEN ; enable 4x PLL for 32-MHz
(...)
Hummm, for I can see your code is wrong, should be:
bsf OSCTUNE, PLLEN
Added after 4 minutes:
some, update:
seems that I'm getting 32MHz
I think, that is a problem with the configs, I will investigate and tell the results ;-)
Added after 1 hours 12 minutes:
Ok, finally works well
The problem is really the SCS1:SCS0 bits, I was wrong.
Note that microchip says in the datasheet 39626C.pdf:
Code:
bit 1-0 SCS1:SCS0: System Clock Select bits
1x = Internal oscillator block
01 = Secondary (Timer1) oscillator
00 = Primary oscillator
So since I wanted to use the "
Internal oscillator block", the datasheet says to use "
1x", but it's
wrong, like xorcise said, to work it need to be "
00", that datasheet says that is to "
Primary oscillator"...
For me, this is really stupid...
Some code that work with 18F2620:
Code:
LIST P=18F2620
#include P18F2620.INC
CONFIG OSC = INTIO67, WDT = OFF, MCLRE = OFF
ORG 0x0000
goto Main
ORG 0x002A
Main
movlw b'01110000'
movwf OSCCON
bsf OSCTUNE, PLLEN
IntOscOK
btfss OSCCON, IOFS
goto IntOscOK
; you code where
END
The IntOscOK loop is only need if the first code that PIC run need the oscillator to be stable ;-)