View previous topic :: View next topic |
Author |
Message |
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
PIC18F26K22 and PLL |
Posted: Tue Nov 05, 2019 8:50 pm |
|
|
Hi
CCS PCH C Compiler, Version 5.062
If I am initializing the oscillator as:
Code: | #use delay(clock=64MHz,crystal=16MHz) |
In the LST file I can see:
Quote: | Configuration Fuses:
Word 1: 3200 HSH PLLEN PRIMARY NOFCMEN NOIESO |
If I initializing the oscillaror as:
Code: | #use delay(internal=64MHz) |
In the LST file I can see:
Quote: | Configuration Fuses:
Word 1: 2800 INTRC_IO NOPLLEN PRIMARY NOFCMEN NOIESO |
In the data sheet, page 28 diagram I see that both internal and external oscillators goes to the PLL unit.
How I can initialize Internal oscillator and get the PLL enable?
Best wishes
Joe
PS: I forget to mention the other fuses:
Code: | #FUSES INTRC_IO//Internal RC Osc, no CLKOUT
#FUSES PLLEN//4X HW PLL enabled |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Wed Nov 06, 2019 12:17 am |
|
|
You already are.
Your INTERNAL=64MHz is enabling the internal oscillator with PLL.
The reason for your confusion is this cannot be done in the fuses.
Instead the compiler adds the extra initialisation at the start of the code
to do it.
Reason is in the data sheet Para 2.8.2:
Quote: |
Unlike external clock modes, when internal clock
modes are enabled, the PLL can only be controlled
through software. The PLLEN control bit of the
OSCTUNE register is used to enable or disable the
PLL operation when the HFINTOSC is used.
|
So the PLL has to be turned on in the software after the boot, and
cannot be enabled in the fuses when using the internal oscillator.
The compiler automatically does this.
Now older compilers did not do this automatically. I think yours is
recent enough that it should be working (how fast is the chip running?),
but it it doesn't then you simply have to add your own
'setup_oscillator' line to set this.
Can confirm (just checked) your compiler does enable the PLL correctly
Fourth line in the generated code:
0000C: BSF OSCTUNE.PLLEN
This is the PLL enable being done right at the start of the code. |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Nov 06, 2019 3:16 am |
|
|
Thank you Ttelmah for the explanation.
Quote: | 0000C: BSF OSCTUNE.PLLEN |
I try to find the above (or part of it) in the LST but didn't find except
NOPLL in the configuration fuses.
Where I should find it?
Best wishes
Joe |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Wed Nov 06, 2019 3:32 am |
|
|
If you look at the list file you should have something like:
Code: |
.................... void main(void)
00004: CLRF FF8
00006: BCF FD0.7
00008: MOVLW 70
0000A: MOVWF FD3
0000C: BSF F9B.6
0000E: BCF F9B.7
00010: MOVLB F
00012: CLRF x38
00014: CLRF x39
00016: CLRF x3A
00018: CLRF F77
0001A: CLRF F78
0001C: CLRF F79
|
The fifth code line down there is the one enabling the PLL. I had set the
compiler to generate 'symbolic' output, which then gives register
names, and makes knowing what it is doing a lot easier... |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Nov 06, 2019 4:27 am |
|
|
Thank you again Ttelmah
I am getting old I forget about this option:
Quote: | set the
compiler to generate 'symbolic' output |
And also because my program have already 22% of the memory the setting will be probably at different location than 0000C.
Quote: | 036C8: BSF OSCTUNE.PLLEN
036CA: BCF OSCTUNE.INTSRC |
Thank you again and have a nice day
Joe |
|
|
|