View previous topic :: View next topic |
Author |
Message |
Brian
Joined: 29 Jun 2010 Posts: 10
|
Pic24: External Crystal not working |
Posted: Tue Jun 29, 2010 6:05 pm |
|
|
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
|
|
Posted: Tue Jun 29, 2010 7:25 pm |
|
|
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
|
|
Posted: Wed Jun 30, 2010 10:37 am |
|
|
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
|
|
Posted: Wed Jun 30, 2010 2:58 pm |
|
|
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
|
|
Posted: Wed Jun 30, 2010 3:41 pm |
|
|
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
|
|
Posted: Wed Jun 30, 2010 4:13 pm |
|
|
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
|
|
Posted: Thu Jul 01, 2010 12:22 am |
|
|
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
|
|
Posted: Fri Jul 02, 2010 10:28 am |
|
|
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? |
|
|
|