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

how to use PIC18F452 with 40 Mhz clock frequency

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



Joined: 17 Nov 2011
Posts: 187

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

how to use PIC18F452 with 40 Mhz clock frequency
PostPosted: Fri Feb 03, 2012 6:57 am     Reply with quote

Hello everybody!
is it possible to use pic18f452 with maximum 40 Mhz?
I think there must be external 40 Mhz oscillator or PPL or something
like that but I don't know how to do this...
(pic18452 datasheet p.17 ...20)
or is it possible to use 40 Mhz crystal in ordinary way.
brgds
arto
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 03, 2012 7:04 am     Reply with quote

Well at least you've got the right pages to read !!
Section 2.5 HS/PLL page 19(21 in PDF reader...)

states.... using a 10MHz xtal and the PLL enabled gives a 40MHz system clock.You have to have HS fuse as well(enables the high speed xtal mode)

You'll have to find the appropriate 'fuse' in the device header and enable them.

looks like the PLL is a fixed X4 mode pll.
artohautala



Joined: 17 Nov 2011
Posts: 187

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

PostPosted: Fri Feb 03, 2012 7:35 am     Reply with quote

temtronic wrote:
Well at least you've got the right pages to read !!
Section 2.5 HS/PLL page 19(21 in PDF reader...)

states.... using a 10MHz xtal and the PLL enabled gives a 40MHz system clock.You have to have HS fuse as well(enables the high speed xtal mode)

You'll have to find the appropriate 'fuse' in the device header and enable them.

looks like the PLL is a fixed X4 mode pll.


Ok thks for your good answer ... I'll try that

Fuses: LP,XT,HS,RC,EC,EC_IO,H4,RC_IO,PROTECT,NOPROTECT,OSCSEN
maybe it must be #fuse HS;
but I don't know how to enable Phase Locked Loop?
artohautala



Joined: 17 Nov 2011
Posts: 187

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

PostPosted: Fri Feb 03, 2012 7:39 am     Reply with quote

temtronic wrote:
Well at least you've got the right pages to read !!
Section 2.5 HS/PLL page 19(21 in PDF reader...)

states.... using a 10MHz xtal and the PLL enabled gives a 40MHz system clock.You have to have HS fuse as well(enables the high speed xtal mode)

You'll have to find the appropriate 'fuse' in the device header and enable them.

looks like the PLL is a fixed X4 mode pll.


is this enough to make work:
//application is using a 10Mhz oscillator, but using the 4x
PLL
//to upscale it to 40Mhz. Compiler will set H4 config bit.
#use delay(clock=40M, oscillator=10M)
and #fuse HS
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Feb 03, 2012 9:25 am     Reply with quote

Or.
Code:

#FUSES H4 //This is HS, with 4* PLL - H4 config bit.....
#use delay(clock=40M)
 

Best Wishes
artohautala



Joined: 17 Nov 2011
Posts: 187

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

PostPosted: Sat Feb 04, 2012 7:38 am     Reply with quote

Ttelmah wrote:
Or.
Code:

#FUSES H4 //This is HS, with 4* PLL - H4 config bit.....
#use delay(clock=40M)
 

Best Wishes


thanks
is it OK if I use 8.867238 Mhz crystal because I don't have exactly 10 Mhz crystal
maybe: #use delay(clock=35.468952M) (=4 times 8.867238 )
or is it important that crystal freq. is int here?
or I have 8 Mhz crystal and maybe it will be: #use delay(clock=32M)

Best Wishes
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Feb 04, 2012 2:49 pm     Reply with quote

Quote:

#use delay(clock=35.468952M) (=4 times 8.867238 )
Code:

 

If you want delays and serial BAUD rate to be accurate
you need to tell the compiler EXACTLY what the clock is.

nuf said ???
Very Happy
artohautala



Joined: 17 Nov 2011
Posts: 187

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

PostPosted: Sun Feb 05, 2012 7:35 am     Reply with quote

asmboy wrote:
Quote:

#use delay(clock=35.468952M) (=4 times 8.867238 )
Code:

 

If you want delays and serial BAUD rate to be accurate
you need to tell the compiler EXACTLY what the clock is.

nuf said ???
Very Happy

Hi, what means nuf?
maybe I purchase 10M crystal because it's much easier to calculate
those delays etc... than with 35.468952M

have fun and thks for your answer
Very Happy
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Feb 05, 2012 7:45 am     Reply with quote

"'nuf said" is short for enough said...

As long as you have the line
#use delay(clock=35.468952M) (=4 times 8.867238 )

The compiler will calibrate the delay_ms() etc routines so they will be
correct. Only if you plan to manually calculate clock cycles would this
be a issue, otherwise use the crystal you have.
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 05, 2012 8:00 am     Reply with quote

Though either will work...

I'd use the 8MHz xtal....less chance of mistyping the value and wonder 'why doesn't the program work...it did before ???'
artohautala



Joined: 17 Nov 2011
Posts: 187

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

PostPosted: Sun Feb 05, 2012 8:47 am     Reply with quote

temtronic wrote:
Though either will work...

I'd use the 8MHz xtal....less chance of mistyping the value and wonder 'why doesn't the program work...it did before ???'


I haven't try it yet.. I'm starting new project and I asked it because
I design new PCB and I didn't know if I have to use
external clock generator or something...
But now I know I can use either 8 Mhz xtal or 10 Mhz xtal
in right way
thks a lot
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