This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Crystal Oscillator & its working

To clock a MCU we use crystal oscillator.How does it actually works.First it require an initialzation to startup oscillating? What exactly this ckt works. Moreover it produces sine wave & MCU works on pulses. Do MCU have inbuilt ckt for converting sine wave into pulses.

  • Aamir Ali said:
    To clock a MCU we use crystal oscillator

    A crystal oscillator is just one of many options.

     

    Aamir Ali said:
    How does it actually works

    It is a standard electronic circuit - the crystal forms the resonant element

    http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/p/135114/555988.aspx#555988

    http://www.lmgtfy.com?q=How+Crystal+Oscillator+Works

    Aamir Ali said:
    First it require an initialzation to startup oscillating?

    No - the oscillator itself is just a hardware circuit; it starts as soon as power is applied (although it takes some time to stabilise).

    However, the microcontroller may have configuratioin options to enable or disable it, to use it or not, to scale its frequency, etc, etc,...

     

    Aamir Ali said:
    it produces sine wave & MCU works on pulses

    A squaring circuit is used.

     

    You might find this basic electronics site useful: http://www.kpsec.freeuk.com/index.htm

     

  • Aamir Ali said:
    ... a MCU ...

    Did you mean that to be a purely generic question, or were you actually asking about some specific MCU?

    My reply was generic.

  • I thought two capacitors connected across crystal to ground are for removing ripples,but I read that along with crystal they form 180 phase shift. But won't cap also removing high freq ripples in this case?

  • Andy is wrong about the 'initialization'. If you use a watch crystal (32768Hz) on XT1, then the default configuration of the MSP is usually that it is activated on power-up.
    Still there is soem software handling required to ensure that the crystal is up. usually by doing a loop around an oscillator fault bit, trying to clear it and checking whether it stays clear. Once it stays clear, the crystal can be used.

    If using the XT2 HF crystal input, however, the oscillator circuit is initially off and needs to be switched on. Also, maybe the por tpins need to be configured. Then the same loop with the oscillator fault bit is required. (older MSPs have only one global oscillator fault for all crystals, the 5x family has separate ones for each oscillator and a global one)

    See the users guide (clock module section) for details and code suggestions.

    Aamir Ali said:
    I thought two capacitors connected across crystal to ground are for removing ripples

    No. They are actually buffers that catch and bounce the charge that flows through the crystal.
    The crystal is a frequency-dependent capacitor on its own. If a voltage is applied, by sending a current through it, it undergoes a mechanical deformation. It literally swells. But as all mechanical actions, a counterforce builds up, inverting the direction at some point. The mechanical dimensions define how fast this happens. Like a mechanical pendulum, where the length defines the frequency, no matter how far you let it swing (how much voltage you apply). When the crstal 'shrinks' again, it creates a voltage in the opposite direction, causing the current to float back where it came from.
    On resonance frequency, its 'mechanical capacitance' matches the capacitance of these two capacitors, so current can flow from one capacitor throught he crystal to the other capacitor and back. The oscillator circuit only needs to replace on the OUT side the energy that is lost by ESR of the three capacitors and by the detector side that turns the almost-sine voltage signal on the IN side into a square wave for further use.

    It would be a good topic for a flash animation. See how the current flows and the voltage builds on the three capacitors.

    P.s.: you can build an oscillator circuit without these capacitors. I twould even faster come up and be more stable, but it would waste LOTS of energy. Magnitudes larger than what the MSPs circuit (a "Pierce oscillator") requires.

  • But capacitors bypass ac through s/g of some freq range depending upon its cap. Won't that will interfere with operation of crystal.

  • Aamir Ali said:
    But capacitors bypass ac through s/g of some freq range depending upon its cap. Won't that will interfere with operation of crystal.

    It allows the operation.

    The crystal itself is a passive element that doesn't do anything on its own.
    Let me draw a picture...

    Imagine an inverse pendulum, that swings from one side up and then down to the other side. That's the crystal. If left alone, it will jsut sit on one side and doesn't swing.
    Now you add two springs on both sides. This are the capacitors.
    If you now gove the pendulum a kick, it will jump up and (if the kick is strong enough) fall to the other side on the other spring and back.
    If the springs are too weak, teh pendulum wil squeeze them together and lose the energy on the impact. If they are too stron, it won't jump back. The springs need to match the mass of the pendulum to make this work. That's why the capacitors need to match the crystal (internal ESR/series+parallel capacitance etc.)
    The frequency of the oszilaltion, however, depends on the length of the pendulum and is independent of the 'mass'. So the capacitors have a large effect on the oszillation strength, but much, much less on the frequency.
    The 'kick' (and the relacement of the energy lost by the ESR of the quartz and the capacitors as well as consumed by the osczillation detector) is provided by the XTOUT driver, which inverts the signal detected by the XTIN side, keeping the kicks in sync with the osczillation.

    Back to the electronic reality, the XTOUT driver pushes a current into teh XTOUT capacitor and the crystal. If a current is pushed into a capacitor, the voltage on it starts to rise. The quartz, however, is rather like an inductor. If a voltage is applied, current begins to flow and energy is stored as mechanical deformation. As the current continues to flow through the crystal into the second capacitor, the voltage on the output side rises until both capacitors have the same voltage. Now the mechanically stored energy in the quartz causes the current to continue flowing, rising the XTIN capcitor voltage further while sucking the XTOUT capacitor dry. When the XTIN voltage crossses a threshold, the XTOUT driver is inverted and now pulls from the OUT capacitor (or at least stops pushing). Then the same procedure happens again in opposite direction.
    The inductive behavior of the quarts is largest when the oscillation frequency matches the mechanical resonance and is determined by the physical shape (the 'cut') of the crystal. So on resonance frequency, the oscillation is strongest. Or rather, the oscillation tends to accelerate/decellerate towards this frequency. As long as the capacitors match the requirements of the crystal.

    This circuit is called a "Pierce Oscillator".

**Attention** This is a public forum