Could you explain how a quartz crystal works, maybe with a simple schematics with the essential things ? I know it acts like a kind of stabilizer for an oscillator, but nothing more than that.
Quartz is a piezoelectric material, which means that if you mechanically deform it, it develops charges on its surface. Similarly, if you place charges on its surface, it causes mechanical stress in the crystal. The way a quartz crystal benefits a circuit is that mechanically the crystal acts much like a tuning fork, with a natural resonant frequency, and the piezoelectric property allows that to be coupled into an electronic circuit. Since the resonant frequency is mainly determined by the physical size and shape of the quartz, you get a frequency reference that is much less sensitive to temperature than you would get using just LC circuits.
Both people have already given great answers, I am just going to try to give a different explanation of the same thing.
BackgroundSo, in a pierce oscillator you have a digital system connected to a crystal oscillator.
Now you have probably seen how logic gates switch state, with a specified rise time. If you put any time into learning about Electromagnetic Compatibility or just high speed digital design(the book by Johnson being the best book in existence), you will learn that this can be looked at as a wide range of frequencies.
What the crystalThere are two ways from this point, from the frequency domain, or from the time domain. I will start with the frequency domain due to personal preference. For every EE I work with I push them to become at home with the frequency domain, many problems become simple here, and complicated responses have meaning.
Frequency DomainFrom the frequency domain, a crystal is a filter at a very specific frequency with a very high Q(quality) factor. This means that of all of those frequencies you generate, you only allow the specific one the crystal allows through.
Time DomainThe other method is to think of a gate tied back on itself. if there was nothing there, it would create a square wave with a frequency equal to the delay, but this frequency is not extremely reliable, and also will vary based on many manufacturing parameters. This is where the crystal affects it. If the crystal has a rising edge placed on it, it will only "pass through" the signal at the frequency it has selected for. Suddenly, the 100MHz square wave becomes a 20MHz sin wave due to the crystal.
A little extra thoughtWonder why oscillators pull so much current, you are charging and discharging the capacitance in the oscillator circuit 20 million times per second. Also, for all the clock cycles many transistors in your circuit do the same. if you do not need speed, a 32KHz oscillator costs very little in power on microcontrollers.
Let me know if I can be more clear.