Re: crystal frequency
Oscillator in a microcontroller is build around a linearized gate, which acts as an amplifier, and Π-network with a crystal as the main component in it - see picture below ..
At power-on this generator starts to generate 'noise' ..
As a crystal is a very, very narrow-band-pass filter of set frequency, it will allow only one frequency to pass through it, then it is amplified and fed back to input through crystal, and so on ..
Finally, when the oscillator stabilizes, the resultant wave is a nice sine wave with (almost) no harmonics in it, and everything becasuse of the narrowness of the filter (crystal) ..
As you know, square wave has a lot of harmonics, but, in this case all of of them, except the fundamental (set by the resonant frequency of the crystal), are filtered out ..
As far as the DC-offset is concerned, it is created by the linearization of the gate (a resistor is connected between input and output) that doesn't act anymore as digital gate but rather as 'linear' amplifier ..
Regards,
IanP