Atmega328p-MU (QFN Package) Acting sporadic

Hello!

I'm having issues with my Atmega328p-MU. It seems as if the Atmega keeps resetting, freezing, and sending out garbage data. I have it pared with two TLC5947 (QFN) Shift Registers.

I'm sure it's the Atmega because the way that I designed the board was to be able to bypass the Atmega to trouble shoot. When using the bypass, the shift registers work correctly.

Not working correctly when using onboard Atmega328P-MU
Sporadic

Working with Bypass
Normal

Schematic

Forgot to add the code,
Just using the adafruit Library for the TLC5947.

#include "Adafruit_TLC5947.h"

// How many boards do you have chained?
#define NUM_TLC5947 2

#define data   11
#define clock   13
#define latch   12
#define oe  -1  // set to -1 to not use the enable pin (its optional)

Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5947, clock, data, latch);

void setup() {
  Serial.begin(9600);

  Serial.println("TLC5947 test");
  tlc.begin();
  if (oe >= 0) {
    pinMode(oe, OUTPUT);
    digitalWrite(oe, LOW);
  }
}

void loop() {
  colorWipe(4095, 0, 0, 100); // "Red" (depending on your LED wiring)
  delay(200);
  colorWipe(0, 4095, 0, 100); // "Green" (depending on your LED wiring)
  delay(200);
  colorWipe(0, 0, 4095, 100); // "Blue" (depending on your LED wiring)
  delay(200);
  rainbowCycle(10);
}


// Fill the dots one after the other with a color
void colorWipe(uint16_t r, uint16_t g, uint16_t b, uint8_t wait) {
  for (uint16_t i = 0; i < 8 * NUM_TLC5947; i++) {
    tlc.setLED(i, r, g, b);
    tlc.write();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint32_t i, j;

  for (j = 0; j < 4096; j++) { // 1 cycle of all colors on wheel
    for (i = 0; i < 8 * NUM_TLC5947; i++) {
      Wheel(i, ((i * 4096 / (8 * NUM_TLC5947)) + j) & 4095);
    }
    tlc.write();
    delay(wait);
  }
}

// Input a value 0 to 4095 to get a color value.
// The colours are a transition r - g - b - back to r.
void Wheel(uint8_t ledn, uint16_t WheelPos) {
  if (WheelPos < 1365) {
    tlc.setLED(ledn, 3 * WheelPos, 4095 - 3 * WheelPos, 0);
  } else if (WheelPos < 2731) {
    WheelPos -= 1365;
    tlc.setLED(ledn, 4095 - 3 * WheelPos, 0, 3 * WheelPos);
  } else {
    WheelPos -= 2731;
    tlc.setLED(ledn, 0, 3 * WheelPos, 4095 - 3 * WheelPos);
  }
}
  • Two de-coupling capacitors just doesn’t cut it.
    You need one capacitor per Vcc/Vdd pin per I.C., mounted very close to the power pin.

Edit

  • You should clean up your soldering.

Thanks For your reply.

The only cap that I have on-hand is a .47uF Electrolytic. I soldered this to the 5VDC and GND pads on the rear of the PCB. And it worked!

Now my question is:

  1. Should I just use another .22 pF Ceramic cap (GRM033C80J224KE90D) across VDC and GND of the atmega?
  2. Put a larger Decoupling cap across the pads on the rear?
  3. Or should I do both?

One last thing was that I was trying to use the same .22pF ceramic cap to decouple one of the TLC5947's and the atmega. Is this a bad practice?

Here is a screenshot of what I mean:

  • I hope you mean 220nF ceramic (a common value is 100nF)

  • Suggest you add 100nF on each Vdd pin.

  • It appears there is no GND plane, next version should be multi layer with an unbroken GND plane.

  • 22uF ceramic bulk capacitor(s) are also needed.

Edit

  • In the future, do not run signal traces under crystals.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.