Circuit for a Crystal (and other related question) used with PIC18F2550

Discussion in 'Embedded Systems and Microcontrollers' started by KansaiRobot, Jun 29, 2015.

  1. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Hello and thanks always.

    I am using the PIC18F2550.
    In my projects so far I have been using the Internal oscillator for non-USB projects and with for USB projects a board containing a PIC18F2553 (similar to 2550) and a crystal of 20MHz. Now the circuit outside OSC1 and OSC2 is similar to Figure 2-2 of the datasheet. crystal.jpg
    According to the recommendations of the datasheet with 20Mhz, C1 and C2 should be 15pF. However my board comes with C1 and C2 of 22pF. This does not represent a problem.

    Now I am planning of building my own board and I only have a 24Mhz crystal at hand. I have already found the changes of configuration I have to do to reproduce the 20Mhz behavior but my question is

    1) What value of capacitors is advisable to use?
    2) what for are these capacitors?

    The crystal I am planning to use is http://www.digikey.jp/Web Export/Supplier Content/Citizen_300/PDF/Citizen_HC49US.pdf?redirected=1

    Now, I found this page:

    https://blog.adafruit.com/2012/01/24/choosing-the-right-crystal-and-caps-for-your-design/

    in which they recommend C1 and C2 in a formula like C1=C2= 2*CL-2*Cstray but how much should I put for CStray??

    --------------

    Now, my other question is in the Table 2-3 they give a series of oscillator configurations but since USB highsepped can only have 48MHz as clock , does this mean I have to always use PLL or use a crystal of 48MHz to directly drive it through USBDIV?? (see Fig 2-1)


    (Just in case, datasheet is here
    http://ww1.microchip.com/downloads/en/devicedoc/39632c.pdf
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Hi,
    Your datasheet suggests a Cstray of 2 to 5pF, but as it states it depends upon your circuit layout.
    I would consider Cstray as 5pF.
    On the 18F2550 with a 20mHz xtal I use 12pF caps, I would suggest this value would be also suitable for your 24mHz xtal.

    For question #2, the PLL expects an internal 4mHz inputs, so using a 24mHz xtal would mean dividing by 6, see image.
    You can also set the CPU clock rate, using the PLL pre-scaler in CONFIG.
    E
     
  3. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    What for are these capacitors??
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    This PDF explains the purpose of the capacitors.
    E
     
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,006
    3,763
    Are you asking "what are the 'stray' capacitors"?

    Stray capacitance is capacitance that your circuit has at various points even though there is no real capacitor present. It comes from pcb tracks running in parallel, and capacitance of various pins of components. In other words, if you add a 12 pF capacitor but your circuit behaves as though you have a 17 pF capacitor, then you have 5 pF of stray capacitance.
     
  6. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    thanks but no, I was asking what those capacitors (for example the 12pF) are for...
     
  7. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,006
    3,763
    @KansaiRobot
    It is part of the filter that make the crystal resonate at the stated frequency. Granted, the filter is a bit tolerant because of the mechanical nature of the crystal but they are still required in many crystal oscillator circuits.
     
  8. KansaiRobot

    Thread Starter Active Member

    Jan 15, 2010
    318
    5
    Today I realized I forgot to put the conclusion here, for anyone who wants to use it.

    I used a 24MHz crystal with 2 20pF capacitors.
     
  9. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    497
  10. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,024
    KansaiRobot likes this.
Loading...