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 CCS Technical Support

PIC 16F648A Oscillator not starting.....

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



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PIC 16F648A Oscillator not starting.....
PostPosted: Tue Jun 08, 2010 6:19 pm     Reply with quote

Hi All,

I've got a very perplexing situation on my hands. I recently updated the PCB for an older design, of which several thousand units have been previously built. The new design adds an FT232R USB IC, and some additional status indicators to the PCB. I modified an old board to prove the new hardware design, and test the new firmware, and this prototype works like a champ. The new PCB's arrived recently, and the first units did not work as expected. In fact, they did not work at all! After fooling around a bit, I quickly determined that the crystal oscillator (4.00 MHz) was not running! Fearing a layout error, I checked that the crystal is connected to the correct PIC pins, and that there is a 20pf capacitor to GND from each crystal pin, and that all appears to be fine. Fearing some insidious manufacturing error with the board I decided to try some basic tests of the board using the internal oscillator on the PIC, so I changed the OSC fuse from XT to INTRC. Strangely, the entire board is now functioning correctly with the exception of the crystal oscillator. So, my new board is 100% functional when using the internal PIC oscillator, and non-functional when using an external 4.00 MHz crystal.

The crystal and the capacitors I'm using haven't changed in years. Here is the crystal: http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=X405-ND The caps are 20pf ceramic disc type.

I've checked the following:

1. Crystal and cap connections to PIC and Gnd.
2. Gnd and +5V connections on PIC.
3. MCLR is being pulled up by a 50K to +5V
4. Decoupling cap is located close to the PIC on the +5V line
5. Crystal is correct type. Tried one from an older working board.
6. Tried various capacitor values from 15pf to 30pf
7. Three board all have the same problem
8. Resistor in crystal circuit does not appear to be needed at 4.00 MHz

I've never had this problem in about 10 years of working with PIC's. I don't see an obvious problem, and I'm running out of ideas. It seems very strange that an older design works great using the same circuit/components, but this new one refuses to work. I don't believe it has anything to do with my code because a chip that works fine in the older board fails in the new board until I enable the internal oscillator, and then everything works just fine.

PIC: 16F648A
Compiler: 4.050
Operating voltage: +5V
Frequency: 4.00 MHz

Any ideas?

Thanks,

John
_________________
John Morley
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 08, 2010 7:36 pm     Reply with quote

Can you post photos of the bare board, zooming in on the area of the
PIC and the crystal circuit ? (Front and back) Also photos of the loaded
board, in the same area. Free image hosting: http://imageshack.us/

I will be looking for Ground Fill around the crystal pads and the caps.
This could stop the oscillation.

Is this a multi-layer board ? Could there be shorts (or connections)
to the crystal circuit from the inner layers (i.e., power and GND) ?
Or, could there be tracks on the inner layers that don't actually
connect to the outer layers, due to bad plated-through holes ?

What package are you using for the PIC ?

As a test, you could go to the rework station and using a microscope,
carefully lift the PIC pins for the oscillator off the pads (assuming you're
using surface mount). If you're using a DIP package, then build a board
with a socket on it, and bend up the two oscillator pins on the PIC.
Then, "dead bug" the crystal and caps on top of the PIC. Pick up the
ground connection for the caps from the Vss pin on the PIC. This test
will isolate the oscillator circuit from the board layout. See if it now works.

Remove the caps and test them in a handheld voltmeter that has a
capacitance meter built-in. Confirm that they are really 20 pf.

Put an Ohmmeter on all pins in the crystal circuit and check for shorts
to anything nearby, including the inner layers (if they exist).

I've used that same crystal. We use this Bivar insulator pad under all
our through-hole crystals:
http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=492-1039-ND
You could test if the crystal is shorting to something underneath it by
installing one with an air gap between the crystal and the board.
This will also test for the small chance that there's a solder short to the
crystal case, by solder wicking through the holes and shorting the pins
to the case.

You could try the HS fuse. See if that makes it work. It's higher power.

You mentioned a (series) resistor in the crystal circuit not being needed.
Presumably you have a 0-ohm resistor in there in its place ? Check that
it's really conductive. Or remove it and put in a jumper.

That's all I can think of for now.
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PostPosted: Wed Jun 09, 2010 12:15 pm     Reply with quote

Hi PCM,

Thanks for taking an interest in my problem, and taking the time to share your thoughts!

Here is a screen shot from my layout software showing the problem PCB:

http://www.analysistech.com/downloads/ProblemBrd.jpg

The crystal is Y1, and the load capacitors are C4 and C5. There are a couple of traces that run under the crystal, and in retrospect this might be an issue? On the top side (in red), one is a +5V connection, and the other is an ICSP connection (Pgm_Dat). On the back side (in blue), one is a digital I/O connection, and the other is a +5V connection.

If an actual picture of the board is useful, I can still provide one, I just thought this one was more effective.

As you can see it's not a multi-layer board, so it's pretty easy to check for proper connectivity.

Shorts do not appear to be a problem as I mounted a crystal with a small air gap as you suggested without seeing any changes.

The caps have been measured with a DVM, and measure '22pf'.

I have checked the crystal connections on the board, and there are no shorts to adjacent connections.

I'm using a thru-hole PIC, so dead-bug mounting a crystal was fairly easy. The circuit works with the dead-bug crystal mounting and the 'XT' fuse setting.

The circuit also works with the crystal mounted in the board and the 'HS' fuse setting. Clearly, the oscillator circuits works, it's just on the hairy edge of some (as yet) unknown specification.

One thing occurred to me. When I added the FT232R chip to the board, I reduced the trace width of my ground connections from 20 mils to 8 mils because of the fine pitch of the FT232R package. This would certainly increase the GND impedance at the load capacitors. To test the theory, I added a supplemental GND connection at the caps but there was no change.

So, it's something related to the board because the dead-bug method works with the XT fuse, but it's not so serious an issue because the unmodified board works with the HS fuse....

I can accept that it's a layout issue, but I'd sure like to know what it is so that I can avoid this problem in the future!

Thanks,

John
_________________
John Morley
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 09, 2010 1:07 pm     Reply with quote

The grounding on this board needs a lot of improvement . It should be a
gridded ground. One side of the board should have a ground track all
around the edges of the board. This track should be 50 to 75 mils wide.
Then going across the board horizontally, there should be several tracks
connecting the two sides of the ground "box". There should also be one
vertical track running roughly down the center of the board, from top to
bottom, connecting to the top and bottom edges of the ground box. The
ground tracks that go across the board should be 50 mils wide if
possible, but 25 mils will work. This is a small board, otherwise I would
have recommended wider tracks (0.1" around the whole board with
50 mils for the horizontal ground tracks.).

A similar thing should be done with the power. Though, the grounding
is more important.

Anywhere that chips or components are connected to ground, you should
use a short, wide connection (25 mils) to one of these grid tracks.

This method basically emulates having a ground plane.

To fix your immediate problem, connect a 22 AWG wire between the
two grounds on the 22 pf caps, and go directly to the Vss pin on the PIC.
Also put a 22 AWG wire from the Vss pin on the PIC to the GND input
for the board.

The diagram below shows what you should try to acheive for your
grounding. It doesn't matter if some of the horizontal tracks go at an
angle for a while. They don't have to be straight. They just have to
connect to the other side, so everything is gridded.
Code:

===================
|        |        |
|        |        |
|=================|
|        |        |
|        |        |
|=================|
|        |        |
|        |        |
|=================|
|        |        |
|        |        |
===================


I have done boards like this and they worked perfectly well.

I have also done boards where the bottom side is a ground plane.
Almost all connections are done on the top side. A few cutouts occur on
the bottom side where I have to run cross-over tracks that can't be
routed on the top.
LostInSpace



Joined: 09 Mar 2010
Posts: 13

View user's profile Send private message

PostPosted: Wed Jun 09, 2010 1:39 pm     Reply with quote

I agree with PCM - it looks like grounding.

To test this remove the two 22pf caps and solder them on the backside of the board from each side of the crystal directly to the ground pin on the PIC.

That should produce a running oscillator.

On the next version of the board flood at least the bottom with copper pour (Top and bottom is even better and tie the top and bottom every 0.2" or so with a ground via) but I make many small boards with just the bottom pour, cuz sometimes I'm lazy too.

It won't cost extra and you will be amazed at how much better everything works.

Just be glad you caught this now instead of during production.

HTH - Steve H.
_________________
HTH - Steve H.
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