3
\$\begingroup\$

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?

\$\endgroup\$
  • 1
    \$\begingroup\$ Yes, if you give it a slower oscillator, it will run slowly. Ex - if you specify 16 MHz and supply an 8 MHz oscillator, delay(500) in arduino will give you a 1 sec delay. \$\endgroup\$ – Whiskeyjack Dec 25 '17 at 5:57
  • \$\begingroup\$ @Whiskeyjack Please do not answer questions in comments. Your answer is not true in general, although it may be for this particular example. \$\endgroup\$ – pipe Dec 25 '17 at 12:44
  • \$\begingroup\$ What did the datasheet for the part say when you read it? \$\endgroup\$ – old_timer Dec 25 '17 at 13:03
  • 1
    \$\begingroup\$ @old_timer it didn't say anything, which is why I'm asking the damn question. Why don't you bugger off with your snide remarks? \$\endgroup\$ – Sod Almighty Dec 26 '17 at 0:13
2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ Can you please elaborate - "ATmegas have static memory, so the clock speed can be as slow as DC or 1Hz." Thanks :) \$\endgroup\$ – Whiskeyjack Dec 25 '17 at 9:41
  • \$\begingroup\$ A high-voltage parallel programmer is pretty much what I'm trying to make. Incidentally, I tried to make a Pierce Oscillator once and it didn't work. I have no idea why. \$\endgroup\$ – Sod Almighty Dec 26 '17 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.