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

Pic24: External Crystal not working

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



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

Pic24: External Crystal not working
PostPosted: Tue Jun 29, 2010 6:05 pm     Reply with quote

Hi,

I am using the pic24hjgp506 PIC and I am trying to get the external crystal to work. I have tried using various different crystals. Currently I am trying a 25 Mhz, 18pF crystal (Part # : se3441-ND).

I have the crystal hooked up the OSC1 and OSC2 pins in parallel with 1Mohm resistor and with the correct capacitors.

I've made my code super simple to test the clock with a blinking LED every second:

Code:


#use delay(clock=25000000)

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES PR                       //Primary Oscillator
#FUSES NOCKSFSM                 //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOOSCIO                  //OSC2 is clock output
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOIESO                     //Internal External Switch Over mode enabled



void main()
{
   while(1)
   {
   
      output_high(PIN_C2);
      delay_ms(1000);
      output_low(PIN_C2);
   }
}



When I have the Internal External Switch Over mode fuse disabled, nothing will even run on the PIC. When it is enabled, it will either get stuck or loop super slow.

What I am I doing wrong here?

Thanks.

Crystal setup:
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 29, 2010 7:25 pm     Reply with quote

You don't have a delay_ms() statement after the output_low() line.
This means it will only be low for an instant. You won't even see it blink.
Brian



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 10:37 am     Reply with quote

Sorry fixed that. Same result though. No LED's are even blinking. It seems like the PIC is not able to run any code.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 2:58 pm     Reply with quote

Quote:
pic24hjgp506

That's not a PIC part number. You left out the middle numbers between
the hj and gp.

Also, post a schematic that shows the complete power and ground,
and MCLR connections to the PIC.
Brian



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 3:41 pm     Reply with quote

Sorry was in a rush. It's the PIC24HJ64GP506.

Here are two pictures of what you asked. One is zoomed in of the PIC connections and the other is more zoomed out to include the additional power circuit. Please note that the crystal circuit is actually set up how I showed in my first posted picture not what is seen here.


PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 30, 2010 4:13 pm     Reply with quote

My first thought would be don't use a 25 MHz crystal initially.
That frequency is near the top end of what the crystal manufacturers
can do it an AT-cut. Conceivably you could have a 3rd overtone
crystal.

It would be better if you used a crystal in the 4 to 20 MHz range.
Remove the 1Meg resistor, change to 22 pf caps and see if it now works.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jul 01, 2010 12:22 am     Reply with quote

If it's an overtone crystal, it would oscillate at about 8.3 MHz in a standard oscillator circuit. The said type is fundamental, however.

The original post suggests, that the processor works correct with internal oscillator, but you don't tell explicitely.
Brian



Joined: 29 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Fri Jul 02, 2010 10:28 am     Reply with quote

Thanks guys. Got it working with an external 8Mhz crystal. The caps I were using were more suited for that crystal rather than the 25 Mhz.

I'm still having trouble sending CAN packets, I thought it might have to do with the external crystal. I have an 8 Mhz external crystal and I'm using the PLL to multipy the frequency times 4 to get 32 Mhz to work with 500 Kbps CAN bit timing. The CAN code that used to work seems to not be working with this external crystal setup. I changed the configuration registers: CICFG1 and CICFG2 to the appropriate values for 32 Mhz crystal at 500 Kbps.

Any suggestions?
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