So if every IC is made of transistors what stops me from putting a ATmega328 on a breadboard with a 20 MHz clock so it will run faster? This is a rhetorical question. I don't need to know how I could do it, I want to know why it wouldn't work.
-
3\$\begingroup\$ "I don't need to know how I could do it, I want to know why it wouldn't work." - that's not what "rhetorical" means. \$\endgroup\$brhans– brhans2022-09-10 20:56:25 +00:00Commented Sep 10, 2022 at 20:56
-
\$\begingroup\$ Who said it wouldn’t work? If you are concerned about speed, you could try a Teensy4 that runs at 800MHz. \$\endgroup\$Kartman– Kartman2022-09-11 03:14:55 +00:00Commented Sep 11, 2022 at 3:14
-
\$\begingroup\$ why cant I bolt a rocket onto a yugo and run it up to 400 miles per hour, I mean the bearings wont melt and the wheels wont come off right? every logic design has a speed limit (within a temperature range). they also have usable temperature ranges for the same reason (you cant put it in liquid nitrogen to try to crank the clock up, the design will fail for other reasons). \$\endgroup\$old_timer– old_timer2023-06-28 05:20:26 +00:00Commented Jun 28, 2023 at 5:20
3 Answers
Many digital ICs, including the atmega328, are made of transistors as you point out - and those transistors can only go so fast. Among other factors, the microscopic wires and the next gate have parasitic capacitances, shown here on the input to a NOT gate:
From an analog standpoint, the previous logic gate's transistors can only supply a limited current and have a non-zero output impedance, so it'll take some brief interval to charge and discharge them.
This means that every logic gate inside the chip has a so-called propagation delay, and when these gates are combined together, these delays add up. Furthermore, the result of these gates needs to arrive at a storage element (e.g. a flip-flop) before the next clock tick (setup time).
In order for your chip to reliably operate at 20 MHz, the propagation delays plus the setup time for clocked elements need to stay within 50 ns. For this chip, the manufacturer guarantees that it'll work under the right conditions. Simply ensure that you meet the voltage requirements specified in the datasheet:

from atmel/microchip datasheet linked above
then add a 20 MHz oscillator or crystal, and enjoy. Note that this is only for the commercial grade part - the automotive grade part is certified more rigorously, and as part of this, the max clock speed is only guaranteed at 16 MHz.
At 25 MHz, the manufacturer makes no guarantees. Some chips from some manufacturing batches might work, they might only work at certain temperatures or voltages, or they may not work at all. At the same time, they could seem to work for hours, and then some particular condition or pattern of inputs causes some path to fail its setup/hold time for a 40 ns clock period, and the chip malfunctions.
Apparently 50 MHz has been achieved in the past, but I wouldn't trust an atmega328 at 50 MHz for anything meaningful.
Anyway, I would speculate that the following are a few reasons why Arduino uses 16 MHz:
- Consistency with other AVR chips that can only run at 16 MHz
- Wider allowable voltage range
- More leeway for poor power supply quality or peripherals that stress the board
Of course, there are processors made of transistors that achieve speeds on the order of GHz - the CPU and GPU in your computer are great examples of this. However, those transistors are much smaller, harder to manufacture, more expensive, designed for lower voltages, more easily damaged, and require good power supply as well as a lot of supporting circuitry. The resulting processor is a very different class of device from the simple and relatively rugged atmega328.
But you can run Mega328 with a 20 MHz crystal, so nothing stops you.
There are two aspects you need to consider:
Can the hardware run at the 20MHz clock speed? Nanofarad's answer addresses that.
Whether the software will work at 20MHz is another question. The speed of the communications link to the host computer used to download the sketches has to match the speed of the Arduino.
One way to achieve that is discussed in this forum thread:
Can you change the crystal from 16MHz to 20MHz?
The boot loader software needs changing so that the host can communicate correctly.
