View previous topic :: View next topic |
Author |
Message |
artohautala
Joined: 17 Nov 2011 Posts: 187
|
how to use PIC18F452 with 40 Mhz clock frequency |
Posted: Fri Feb 03, 2012 6:57 am |
|
|
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
|
|
Posted: Fri Feb 03, 2012 7:04 am |
|
|
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
|
|
Posted: Fri Feb 03, 2012 7:35 am |
|
|
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
|
|
Posted: Fri Feb 03, 2012 7:39 am |
|
|
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
|
|
Posted: Fri Feb 03, 2012 9:25 am |
|
|
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
|
|
Posted: Sat Feb 04, 2012 7:38 am |
|
|
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
|
|
Posted: Sat Feb 04, 2012 2:49 pm |
|
|
Quote: |
#use delay(clock=35.468952M) (=4 times 8.867238 )
|
If you want delays and serial BAUD rate to be accurate
you need to tell the compiler EXACTLY what the clock is.
nuf said ???
|
|
|
artohautala
Joined: 17 Nov 2011 Posts: 187
|
|
Posted: Sun Feb 05, 2012 7:35 am |
|
|
asmboy wrote: | Quote: |
#use delay(clock=35.468952M) (=4 times 8.867238 )
|
If you want delays and serial BAUD rate to be accurate
you need to tell the compiler EXACTLY what the clock is.
nuf said ???
|
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
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun Feb 05, 2012 7:45 am |
|
|
"'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
|
|
Posted: Sun Feb 05, 2012 8:00 am |
|
|
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
|
|
Posted: Sun Feb 05, 2012 8:47 am |
|
|
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 |
|
|
|