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 support@ccsinfo.com

How can use the 40Mhz crystal for PIC 18f4525

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



Joined: 09 Nov 2006
Posts: 1

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

How can use the 40Mhz crystal for PIC 18f4525
PostPosted: Thu Nov 09, 2006 11:24 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Nov 09, 2006 12:07 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 14, 2006 11:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 14, 2006 12:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Nov 14, 2006 12:41 pm     Reply with quote

what is the difference between the two? crystal and oscillator
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 14, 2006 2:57 pm     Reply with quote

The crystal consists only of a quartz crystal. It must be connected
to an oscillator circuit to create the output signal. The oscillator circuit
is inside the PIC. Example of a crystal:
http://rocky.digikey.com/WebLib/ECS/Web%20Photos/HC-49US.jpg

The oscillator consists of both a quartz crystal and an oscillator circuit
in one package. It only requires that power and ground be connected
to it, and then it will generate an output signal. Example:
http://rocky.digikey.com/WebLib/CTS/Web%20photos/MXO45.jpg
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