0
\$\begingroup\$

The standard barebone setup would be with a 16Mhz crystal oscillator and 2 caps:

https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

However unfortunately I only have the following crystals available:

12.000 Mhz

33.8688 Mhz

24 Mhz

27 Mhz

Is it possible to use the chip with these and how would it effect the run? I have some delays in the code which should be respected but no need for accurate timing, if it's shifting a bit (eg there is a delay for 5 minutes and it's 4.9 instead that's ok).

| improve this question | | | | |
\$\endgroup\$
  • \$\begingroup\$ A Crystal is a crystal and not a crystal oscillator. It’s a bit like referring to your vehicle tyres as wheels. \$\endgroup\$ – Andy aka Mar 7 at 16:50
  • \$\begingroup\$ I don't know what's possible in the Arduino IDE because I don't use Arduino, but the mega328p doesn't need any external crystal at all to function properly. It has an (accurate enough) internal 8MHz clock, which by default is scaled down to 1MHz. This prescaling can be changed by programming certain fuse bits, but you can also change scaling dynamically in your code. With that said, if you use any Arduino libraries that expect a 16MHz CPU frequency (like the serial communications stuff), the baud rates will all be messed up. If you are using any serial comms, I do recommend an external xtal. \$\endgroup\$ – Kurt E. Clothier Apr 17 at 13:46
2
\$\begingroup\$

I’m assuming you’re using the Arduino IDE here... which I realize might not be what you’re looking for.

It’s possible to use any crystal or ceramic oscillator up to 20MHz with the right capacitors (or no capacitors if you use a ceramic oscillator with built-in caps). You could also use the internal 8MHz oscillator.

You could use a non-standard bootloader like minicore.

Minicore supports 12MHz out of the box, in addition to other non-standard crystal frequencies and will make sure all timing-sensitive things like millis(), delay() and baud rates will still work correctly.

First, you need to install the Minicore Board Manager as described in the page I linked to.

Then you need to flash the Minicore bootloader to your ATMega.

24, 27 and 33MHz are beyond the ATMega328 specifications so I don’t recommend those (except if you’re feeling lucky, but you risk bricking your ATMega).

| improve this answer | | | | |
\$\endgroup\$
1
\$\begingroup\$

You can go with 12 MHz. The other frequencies are not supported by the MCU as such.

Please note that you should have right settings in the clock distribution internally so that the tick is right. If you directly use 12 MHz instead of 16 MHz, the timing will be slower by 25%.

Last option is also to use the not accurate low frequency internal RC oscillator. You have to set the clock register bit settings accordingly.

If you do not want to change the clock settings you have to buy a 16 MHz crystal only. Else, UART baud (for example) will be out of the standard recommendation.

enter image description hereenter image description hereenter image description here

| improve this answer | | | | |
\$\endgroup\$

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.