CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18F26K22 and PLL

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PIC18F26K22 and PLL
PostPosted: Tue Nov 05, 2019 8:50 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 06, 2019 12:17 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 06, 2019 3:16 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 06, 2019 3:32 am     Reply with quote

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... Smile
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Wed Nov 06, 2019 4:27 am     Reply with quote

Thank you again Ttelmah Smile

I am getting old Sad 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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group