Crystal choice
In an avr project, what are implications of choosing 8MHz crystal with no prescaler vs 16MHz one with div2?
Posted Mar 9, 2016, 6:42 PM UTC
34
In an avr project, what are implications of choosing 8MHz crystal with no prescaler vs 16MHz one with div2?
Posted Mar 9, 2016, 6:42 PM UTC
Duty cycle.
With a div 2 divider you're sure the duty cycle is exactly 50%.
???
In a crystal oscillator, the crystal goes through two phases: it undergoes compression while subjected to a current, and then goes into relaxation during which it generates a current. The rest of the oscillator circuit senses that current and drives the crystal back into compression and so the cycle is repeated.
The signal that drives the crystal is also used as the output, so it goes on, off, on, off, on, off, on, off... etc...
Because of the electro-mechanical nature of the crystal, as well as the sensing parameters of the circuit the on and off (compression and relaxation) phases may differ a bit in duration. Maybe the crystal relaxes a bit more slowly than it compresses, or the circuit senses the change from one state to another a bit late and the other change a bit early.
For a clock the most usual ideal shape is for the signal to be in on state for a time, and then be off for the exact same time and the cycle repeats. When the signal is such, it's called 50% duty cycle; it spends 50% of its time while on, and 50% while off, like so:
If it spends 60% on and 40% off:
Notice that the frequency is the same because both phases still add up to 100% of the period.
A 10% duty cycle:
Digital circuits which require a clock may use the two phases in order to do different things each cycle. If the duty cycle of the signal is 50%, the circuits have equal time slices to do both things. If however the duty cycle is 10% the circuits have a very short time to do one thing, and then they're left "twiddling their thumbs" during the other phase. Not efficient and the short phase may prevent stable operation; the circuit may not have enough time to do its thing.
So 50% duty cycle is very often preferable.
If we take a signal and divide it by two, that usually involves a bit of circuitry that takes a signal and senses a condition that happens only once in a cycle and each time that condition happens it toggles a bit which it outputs. So from this signal:
The divider might toggle its output bit when the input changes from on to off, so the resulting output is:
So while the input is 80% duty cycle, the output is exactly 50%, at half the frequency.
Does all this matter in AVR projects? Not really. The guys at Atmel designed their crystal oscillator very carefully so that the phases are of pretty much identical length.
It used to matter, in olden days when we old guys drove our crystals sloppily with transistor circuits.
Thanks. That was enlightening. :)