Electronic – Can a microcontroller work from an oscillator if it is expecting a crystal

atmegacrystalmicrocontrolleroscillator

I'm designing a circuit that will accept and program various microcontrollers, e.g. Atmel's ATmega328P.

These microcontrollers usually have so-called "fuses" to configure their clock sources, and they generally offer the following options:

  1. Internal oscillator
  2. External crystal
  3. External oscillator

My question is simple: If the microcontroller is configured to expect a crystal, will it work correctly if you instead provide it with an external oscillator?

For extra credit: What will happen if you give it a slower oscillator? Will it just perform more slowly?

Best Answer

Almost every microcontroller that can use a crystal is designed to have a Pierce oscillator. You can see some more details here AN2049 (not just limited to Freescale). Your MCU has XTAL1 and XTAL2 pins, one is the "input" the other is the "output" of the oscillator.

I am not sure what you mean by "external oscillator". ATmegas usually can run from an internal oscillator, external crystal oscillator, external ceramic oscillator and external clock signal.

I think that no matter the fuse settings, you could always supply an external clock signal (strong enough to drive the gate inside) to the XTAL input pin. For example - use a crystal generator (the one on the right): https://upload.wikimedia.org/wikipedia/commons/6/6e/18MHZ_12MHZ_Crystal_110.jpg https://upload.wikimedia.org/wikipedia/commons/6/6e/18MHZ_12MHZ_Crystal_110.jpg

ATmegas have static memory, so the clock speed can be as slow as DC or 1Hz. The MCU will just run slower. Keep in mind that there is a relation between MCU speed and maximum ISP programming speed, so your USBasp or another programmer may not be able to connect to an MCU running at 1Hz.

If you want to be able to access any AVR, no matter the fuse settings (clock type is just one of many), then you need high-voltage parallel (or serial for some Tinys) programmer anyway, like the AVR Dragon