View previous topic :: View next topic |
Author |
Message |
farmada
Joined: 09 Nov 2006 Posts: 1
|
How can use the 40Mhz crystal for PIC 18f4525 |
Posted: Thu Nov 09, 2006 11:24 am |
|
|
Hi!.
I need to know how can I config the "#fuse" for use a 40Mhz crystal.
I should put ?
Code: | #fuses H4,NOWDT,NOLVP,NOBROWNOUT,NOPBADEN,PUT,NOXINST,NOMCLR,NOLPT1OSC,NOWRT,NOWRTD,EBTR,NOCPB,EBTRB,NOWRTC,NOWRTB,PROTECT,CPD
#use delay(clock=40000000) |
If there are anything else that colud ask me ?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 09, 2006 12:07 pm |
|
|
You need to use a 10 MHz crystal. The PLL multiplies the frequency by 4
to create the 40 MHz clock. Use the H4 fuse, as you are doing. |
|
|
new2ccs
Joined: 29 Oct 2006 Posts: 10
|
|
Posted: Tue Nov 14, 2006 11:10 am |
|
|
if a program is designed to use 20Mhz for picdem 2+
#fuses HS, NOWDT, NOLVP, PUT
this is for the tones driver program that i downloaded from this forum. I have the xtal of 4Mhz. This means that i have to buy a 20Mhz xtal or I can configure the code to be equivalent to 20Mhz with my 4Mhz xtal. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 14, 2006 12:26 pm |
|
|
Quote: | Can I configure the code to be equivalent to 20Mhz with my 4Mhz xtal. |
No. But you can make it run at 16 MHz.
The PicDem2-Plus comes with a 4 MHz oscillator (not a crystal).
It looks like this:
http://rocky.digikey.com/WebLib/CTS/Web%20photos/MXO45.jpg
A crystal that can be used with the PicDem2-Plus board will look
like this:
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg
(The PicDem2-Plus does not come with a crystal).
Remove the 16F877 from the PicDem2-Plus board and install the 18F452.
Then compile the following program and use the ICD2 to program it into
the 18F452. After programming the PIC, remove the power connector
from the board and then re-insert it. It's necessary to "cycle the power"
to put the PIC into 4x PLL mode. After you do this, the PIC will run at
16 MHz (with a 4 MHz oscillator input).
The following program demonstrates blinking the RB0 LED on the
PicDem2-Plus, while running in 4x PLL mode. Notice that the
#use delay() statement is set for 16 MHz:
Code: |
#include <18F452.h>
#fuses H4, NOWDT, PUT ,BROWNOUT, NOLVP
#use delay(clock=16000000)
//====================================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
new2ccs
Joined: 29 Oct 2006 Posts: 10
|
|
Posted: Tue Nov 14, 2006 12:41 pm |
|
|
what is the difference between the two? crystal and oscillator |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|