Standalone ATMega328 and MAX7219 chain - Clock issue?

Hi guys,

I’ve been using the ATMega 328p and MAX7219 combo on several projects with great satisfaction. However, my latest project has brought me to a full stop.

Most of my setups are pretty simple: 1 ATMega 328p + 1 MAX7219 + a bunch of LEDs or 7 segments. I like designing my own PCBs so I tend to minimize the ATMega’s setup to the processor, 2 capacitors and the reset resistor. In that case, I run it on the internal oscillator. To program it, I use Nick Gammon’s board programmer with Arduino ISP.

My latest project is a simple clock based on a DS3231 RTC module with 1 ATMega 328 and 4 MAX7219 driving 7 segments displays as well as the analogic seconds display. When I’ve started soldering and testing the PCB I designed, I noticed that after a few minutes, the digits start flickering like crazy or the program simply resets, or it hangs.

The breadboard setup I have for this project has:

  • 1 standalone ATMega328p @8MHz
  • 6 MAX7219 drivers on eBay “tube” or “matrix” modules (2 of them unused on a 3-chain)
  • 4 distinct LedControl libraries

The production PCB has:

  • 1 ATMega328p @8MHz
  • 4 separate MAX7219 drivers, 3 of them in a chain
  • 2 distinct LedControl libraries

As I’ve read on this forum that cheap MAX7219 I get off eBay are not that good with chains and long wires, I’ve made the wires as short as possible. To be honest, I had a lot of trouble pin-pointing that on the breadboard setup and I’ve spent days looking at faulty displays (only 1 digit in 8 lighting up, for instance).

Now, on the production board, I’m wondering whether the internal oscillator of the processor may be at fault and I should have run it at 16Mhz with a crystal. On the breadboard setup it works fine (with no chain) and on one of my other projects I have 5 MAX7219 in a chain working fine but with an ATMega328p @16Mhz with an external oscillator.

I’m at a loss here, do you have any ideas? Of course, I’ll provide you with any additional details if needed.



Show a good image of your wiring and a schematic.

Always use decoupling on all your I.C.s


I didn't post them at first because I didn't know if they would be helpful, there you go !



PCB 1.2 LT.pdf (60.2 KB)


Looks like you only have one decoupling capacitor on the board.

You NEED one per I.C., mounted at the Vcc pin of each chip.

I see no decoupling at the power supply connector and no supply capacitor either.

The max7219 data sheet recommends a 0.1uF and a 10uF cap for each chip.

Also I see some LEDs without series resistors in your schematic. Not the ones connected to the max chips, they would not be needed. But several others.

The ATmega internal 8MHz Vs external 16MHz question is not relavent, you can use either. The ATmega communicates with the max chips over the SPI bus, which is a "synchronous" bus, meaning it has a separate clock line. That means that a wide range of clock speeds can be used and minor variations in the clock timing don't matter. Contrast that with "asynchronous" busses such as Serial. With asynchronous busses there is no separate clock line, so data timing is much more critical and sometimes errors can occur if an accurate crystal is not used by both the sending and receiving circuits.


Thanks for your answers!

Nice to know I can use the ATMega @8Mhz. You are both perfectly right about the decoupling capacitors, when I checked the boards I designed for my working chain project, I see immediately that I put 2 caps per Maxim chip (0.1µF and 10µF). And on my current breadboard setup, each eBay module has at least one cap.

I got overconfident: when I designed my clock I just took a glance at the MAX7219 datasheet, which on the first page does not mention the caps (see attachments)... and I forgot them stupidly!

I'll write that down on my idiot checklist :slight_smile:

As for the LEDs without resistors, it's just a shortcut I took with Eagle because I wanted a smaller footprint for my resistors. So whenever you see 2 LEDs in series on the schematic, it's in fact 1 LED and 1 resistor.

Do I need a decoupling & supply capacitor on the power connector since the clock will be powered on the USB port of a computer? Could they prevent unwanted reboots?

Thanks again,




If in doubt, put the caps in. They certainly won't do any harm.

Have you calculate the maximum current so those LEDs could draw? Will usb be able to supply that much?

Yes, I will redesign my board with a few optimizations and 2 caps by MAX7219.

I've just measured the breadboard prototype, it draws between 130 and 150 mA. I find it to be quite low, but it's a realistic model since it has all the parts in need (including caps :)).

I think a standard USB port can handle up to 500mA so I should be fine.