View previous topic :: View next topic |
Author |
Message |
KL
Joined: 24 Feb 2004 Posts: 11
|
Osc problem with 18LF4525 |
Posted: Mon Oct 08, 2012 2:54 pm |
|
|
I'm using a PIC18LF4525 and can not see the 20 Mhz clock signal with the O-scope. The chip powers up and appears to run off the internal clock. I initially used a developer board with a PIC18LF4525 to develop the code and it works fine on that board. I set the fuses as shown:
Code: |
#include <18F4525.h>
#device adc=10
#device *=16
#device ICD=TRUE
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH)
// >10mhz for PCD)
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES PUT //Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOPBADEN //PORTB pins are configured as digital I/O
// on RESET
#FUSES LPT1OSC //Timer1 configured for low-power
// operation
#FUSES MCLR //Master Clear pin enabled
#use delay(clock=20000000)
#use fast_IO(A)
#use fast_IO(B)
#use fast_IO(C)
#use fast_IO(D)
#use fast_IO(E) |
In the "main" I have set
Code: |
set_tris_a (0xC1); // 3 inputs, 5 outputs
|
Is it possible there is a SW setting I have overlooked that would diminish the osc signal on the PIC? Or could I have a bad crystal? I have 2 new boards with the same problem. I have changed the crystal and caps without any success. I'm using ECS-200-20-4XDN along with 20pf, Digi Key 399-1196-1-ND caps.
Any feedback is appreciated.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 08, 2012 3:14 pm |
|
|
What's the Vdd voltage on the PIC ? |
|
|
KL
Joined: 24 Feb 2004 Posts: 11
|
|
Posted: Mon Oct 08, 2012 3:25 pm |
|
|
VDD = 5V . |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 08, 2012 3:49 pm |
|
|
I have an 18LF4620, which is in the same PIC family (same data sheet)
as the 18LF4525. It works for me. I ran it at +5v and I see a 20 MHz
0 to 5v sinewave on pin 14 of the PIC. I tested it with compiler vs. 4.137.
Do you have a pull-up resistor (to +5v) on the MCLR pin ? You need one.
Is the crystal connected between pins RA6 and RA7 (pins 14 and 13) ? |
|
|
KL
Joined: 24 Feb 2004 Posts: 11
|
|
Posted: Mon Oct 08, 2012 3:58 pm |
|
|
I have a pull up to 5V+ on MCLR. Also, the new board has a TQFP package and I have the osc leads on RA6 and RA7, pins 30 and 31.
Thanks for the feedback |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 08, 2012 4:31 pm |
|
|
First, try it without the ICD enabled. Comment it out like this and
re-compile and test it.
Code: | // #device ICD=TRUE |
That's because CCS changes PUT and BROWNOUT to NOPUT and
NOBROWNOUT when you use the ICD. (And other fuses are changed
as well). This could potentially be the cause of your problems.
Also try disabling the FCMEN fuse. Change your current fuse setting to this:
|
|
|
KL
Joined: 24 Feb 2004 Posts: 11
|
|
Posted: Mon Oct 08, 2012 4:50 pm |
|
|
I tried both options and still have the same problem.
Thanks, |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19550
|
|
Posted: Tue Oct 09, 2012 2:22 am |
|
|
As a comment, the capacitors you are using are _not_ correct for the crystal. It should though still work.
On a crystal, you want the total capacitance of the circuit, that the crystal 'sees' in parallel with it, to equal the load capacitance. For this crystal 20pF. Now the two capacitors put onto the crystal, are seen _in series_ with each other, and in parallel with the pin capacitances, to give the 'load'.
So (for instance), if the pins have 3pF capacitance to ground each, with your 20pF capacitors, the two capacitors are seen by the crystal _in series with each other, paralleled by their pin capacitances_. So you get:
(20+3)/2 = 11.5pF
Nowhere near the 20pF required.
This is why typical capacitors on the crystal circuits are 33pF, for crystals requiring 20pF. Gives about 18 to 19pF seen by the crystal. 20pF capacitors are normally used for crystals requiring perhaps 12pF load.
Typically pin capacitances are around 3pF, to 5pF (if the board is not so carefully cleaned).
I agree about the comments on relieving the ground plane.
Other thing is it is sometimes necessary to add a large parallel resistance to the crystal to ensure clean start-up - perhaps 1MR. However if you are seeing some oscillation this is not the problem.
Best Wishes |
|
|
KL
Joined: 24 Feb 2004 Posts: 11
|
|
Posted: Tue Oct 09, 2012 4:28 pm |
|
|
Thank you for the feedback. I increased the capacitance and added the 1M across the crystal and I now have a 20Mhz clock signal. |
|
|
|