Change OSCCON = $72 to OSCCON = $70 (%01110000).
Change OSCCON = $72 to OSCCON = $70 (%01110000).
Hi Bruce,
Thanks very much. I actually got the same advice from PIC Basic support - although the $72 value was given to me by support earlier, and matched teh value I was using. This does indeed fix it - I see now that the PIC is configured to use the "main oscillator" rather than the internal - but could you please explain why? I was assuming the internal oscillator was everything internal and the main oscillator was an external crystal or RC.
To avoid any confusion to those that may notice - the first OSCCON value I posted had OSCCON=$7F. This was copied/pasted from a file in which I was thoughtlessly monkeying with the values attempting to fix it.
The primary oscillators include the External Crystal and Resonator modes, the
External RC modes, the External Clock modes and the internal oscillator block.
You set the "primary" oscillator with FOSC3:FOSC0 configuration bits - so with
the internal oscillator block set in CONFIG1H, and 8MHz or 4MHz selected in
OSCCON, you need System Clock Select bits SCS1:SCS0 set for "primary" for
PLL to work.
The PLL is available only when it's configured to use the internal oscillator
block as its "primary" clock source (FOSC3:FOSC0 = 1001 or 1000).
It's not exactly hit-you-in-the-face clear from looking at the datasheet, but
that's the only way to turn on PLL when using the internal osc.
I had exactly the same problem with PIC18F1330. But I could fix it using the Bruce advice:
movlw B'0111000'
movwf OSCCON, A
But there is a strange behavior of the MPLAB-SIM. If I do this:
movlw B'0111011'
movwf OSCCON, A
The simulator do not write the two lower bits, as you can see in this image (click to enlarge):
But in the hardware the two bits are written, that's the reason because the PLL hadn't worked in my prototype.
Bookmarks