1

Does anyone know what the max clock speed of the ATMEGA328P is, without the clock divider? I know that people have been able to overclock the 328 to 30 - 50 Mhz, but I haven't found if those are using the clock divider or not.

I'm working on reverse engineering a project that uses an atmega to interface with an NES's CPU. The clock on the circuit is a 20 Mhz clock, but the project doesn't mention what fuses to set for the atmega. Looking at the code, it seems like the intention is to run one instruction on the atmega for each input clock cycle.

Is it possible to run the ATMEGA328P at 20 Mhz with the clock divider turned off? In my experiments with a simple blinking LED program, the LED will phase in and out of blinking at the correct speed and blinking too rapidly. As soon as I re-enable the clock divider (and adjust F_CPU) it blinks at a stable rate again.

Am I doing something wrong, or am I running the atmega too far out of spec?

rcole
  • 11
  • 1

1 Answers1

3

If you open up the chip datasheet, the maximum frequency of Atmega328P is 20 MHz. It will need at least 4.5V tor run at that speed. And if you want it to run at 20MHz with a 20MHz clock, the clock divider needs to be 1 so it does not run on slower clock than 20MHz.

You can't change the clock speed by changing F_CPU. The F_CPU tells to the compiler and libraries what speed the CPU is actually running, so you must first modify the hardware to run at the clock you want and tell what the clock is to the software by setting the F_CPU accordingly.

Also, overclocking means running the chip outside its intended parameters. If you overclock it, there is no guarantee if it works, and if it does not work, what part will fail first.

Justme
  • 127,425
  • 3
  • 97
  • 261
  • When the data sheet specifies 20MHz, is that without the clock divider? It does not seem to clarify whether that is with or without the clock divider. On F_CPU: I just wanted to clarify that I was changing it so that I wasn't surprised that increasing clock speed decreased delay times. – rcole Mar 06 '21 at 18:49
  • It runs internally at 20 MHz when a 20 MHz clock is fed to it when divider is set to 1 so without the clock divider. It can't be run internally at any higher clock than 20 MHz and it can't be fed with any higher external clock than 20 MHz. – Justme Mar 06 '21 at 19:05