+ Reply to Thread
Results 1 to 9 of 9

Thread: PIC/crystal startup problem

  1. #1
    Futterama Newbie
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    163

    Default PIC/crystal startup problem

    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:
    http://elektronik-lavpris.dk/eshop/s...p?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


  2. #2
    mrmonteith Newbie
    Join Date
    Feb 2008
    Posts
    38

    Default

    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

  3. #3
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    Default

    @Futterama,

    Try placing a 1Mohm resistor across the 8MHz Xtal to see if it helps.
    L.Chung

  4. #4
    eng1 Excellent eng1 Excellent eng1 Excellent eng1 Excellent eng1 Excellent
    Join Date
    Apr 2006
    Location
    Italy
    Posts
    938

    Default

    Quote Originally Posted by Futterama
    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.

  5. #5
    Futterama Newbie
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    163

    Default

    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:
    Attached Images

  6. #6
    Futterama Newbie
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    163

    Default

    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...

  7. #7
    BeeBop Excellent BeeBop Excellent BeeBop Excellent BeeBop Excellent BeeBop Excellent BeeBop Excellent
    Join Date
    Dec 2005
    Location
    Vancouver Canada
    Posts
    1,193

    Default

    Quote Originally Posted by Futterama
    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.

  8. #8
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    Default

    Quote Originally Posted by Futterama
    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?
    L.Chung

  9. #9
    Futterama Newbie
    Join Date
    Mar 2004
    Location
    Denmark
    Posts
    163

    Default

    Quote Originally Posted by eblc1388
    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.

+ Reply to Thread

Similar Threads

  1. Keil C problem
    By sarang1_in in forum Micro Controllers
    Replies: 3
    Latest: 27th February 2005, 05:05 AM
  2. Problem; Random pic performance
    By timothyjackson in forum Micro Controllers
    Replies: 7
    Latest: 19th February 2005, 06:20 PM
  3. Big problem!!
    By zezito in forum Electronic Projects Design/Ideas/Reviews
    Replies: 4
    Latest: 29th October 2004, 02:05 AM
  4. 12F675 Problem
    By brodin in forum Micro Controllers
    Replies: 10
    Latest: 29th December 2003, 09:40 PM
  5. strange color camera problem
    By schrodingerscat in forum Electronic Projects Design/Ideas/Reviews
    Replies: 5
    Latest: 4th October 2003, 07:25 PM

Tags for this Thread