Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC/crystal startup problem

Status
Not open for further replies.

Futterama

Member
Hello forum,

I'm building a handheld RPM counter for a hobby gasoline engine.

I'm having problems with the PIC not starting up when power is applied. I used my scope, and it seems like the crystal oscillator doesn't start to oscillate. If I use the internal OSC it seems to work just fine.

I'm using the PIC16F88 with a 8MHz Fundamental 50ppm crystal and I started out with 2x15pF caps for the crystal.

I read in some forum that two different value caps would solve my problem and the PIC datasheet says a larger value would stabalize the crystal more, so I tried to use 33pF and 39pF. This does not solve my problem.

Here is a bit data for the crystal:
https://elektronik-lavpris.dk/eshop/showproduct.asp?PRO_ID=86029

The crystal is placed at the end of the PIC (DIP18 package) with the PCB traces going under the PIC. The caps are located right next to the crystal. I will upload a PCB design and a photo later today.

I need the accuracy of the crystal in this project.

Please advise.

Thanks.


Regards,
Futterama
 
I've only worked with the internal oscillator so far. But the 16F88 is a bit quirky thing. For one do you have a 10k pullup on /MCLR? According to the datasheet those caps should work but do you have a resistor between the crystal and OSC2 pin? Other than that we'd need to see what configuration bits you have set and the OSCCON bits set at.

I'd like to know what solves this because I'll be running into this shortly.

Michael
 
Futterama said:
I'm having problems with the PIC not starting up when power is applied. I used my scope, and it seems like the crystal oscillator doesn't start to oscillate. If I use the internal OSC it seems to work just fine.
Can you show your configuration settings? An 8 MHz crystal must be driven in HS mode, not in XT mode.
On a side note, use a scope with a x10 probe when you test your crystal oscillator. If you use a x1 probe, the oscillator usually stops.
 
Config in CCS PICC:

#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection

My PICkit 2 programmer shows these configuration bits: 3F02 0003.

I don't have a pullup on MCLR, I did try to put one on when I had the problem, but that didn't help - and it shouldn't (FUSES NOMCLR). I dont have the resistor one the OSC2 pin, this would be my next try - but what value should I use?

I'll try the 1Mohm resistor just now.

Heres a shot of the traces:
 

Attachments

  • crystal_board.jpg
    crystal_board.jpg
    112.2 KB · Views: 425
Oh my god, I feel very silly right now.

When I experienced the problem, was after the PIC had gone to sleep - and the circuit includes a 10µF cap - so the cap must have powered the PIC and when I re-applied the external power, the PIC was still sleeping - hence no oscillation on the crystal. If I discharge the cap before applying power again, the thing works. DOH!

I'm sorry I have wasted your time...
 
Futterama said:
Oh my god, I feel very silly right now.

When I experienced the problem, was after the PIC had gone to sleep - and the circuit includes a 10µF cap - so the cap must have powered the PIC and when I re-applied the external power, the PIC was still sleeping - hence no oscillation on the crystal. If I discharge the cap before applying power again, the thing works. DOH!

I'm sorry I have wasted your time...

Quite the contrary; you have provided the solution yourself, after some reflection, and posted that solution. If someone else, in the future, has this same problem, they will find your information if they search for it.:)
 
Futterama said:
If I use the internal OSC it seems to work just fine.

Why is there a difference between using internal oscillator and external Xtal, after the PIC is put to sleep and power maintained via an external 10uF capacitor?
 
eblc1388 said:
Why is there a difference between using internal oscillator and external Xtal, after the PIC is put to sleep and power maintained via an external 10uF capacitor?
Actually, there is no difference, but my PIC will go to sleep after 30 seconds after power is initially applied and it will stay asleep for awhile even if I remove the power. What I did was measuring the crystal OSC when appliyng power again, and there was no OSC - and I didn't think that the PIC was asleep, I thought it had problems starting up. So I rewrote my program to use the internal OSC, and programmed the PIC. The programming would take the PIC out of sleep, and the PIC seemed to work fine. Then I reprogrammed the PIC back to using the crystal, and the PIC worked fine again - until after 30 seconds where it would go to sleep again and removing the power for a short while would not reset the program. So to me it seemed like an unstable crystal startup.
 
Status
Not open for further replies.

Latest threads

Back
Top