0
\$\begingroup\$

I designed a standalone ATmega328p board (like an Arduino Nano). I use an Arduino Nano as an ISP Programmer, I can set the fuse bits and flash the program to it. But the ATmega shows absolutely no signs of life (I built an LED with resistor on pin PB2 and wanted it to make blink).

Tried another pin - not working. No signs of life at all. All the parts except the ISP connector were soldered by the JLCBPCB SMT service.

Here is the schematic:

enter image description here

And here are the pictures of the PCB design:

Top Layer:

enter image description here

Bottom Layer:

enter image description here

Did I make a design error which I'm not seeing or is the chip maybe just broken?

I let JLC assemble two boards and they both behave the same - setting fuse bits and flashing the program - possible. But blinking an LED - No. Absolutely no signs of life.

I personally doubt it, that BOTH chips are broken - as they are brand new.

Has anyone encountered a similar problem? Thanks for your help.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ Well, we don't know what components you used. Which 16 MHz device that is, a crystal or ceramic resonator? In which way you programmed the fuse bits? Have you determined that the LED is simply not mounted correctly but your program runs correctly? We also don't see what program you wrote, maybe there is a bug. Maybe the problem is just the missing bypass capacitors for supply, but it might not even program correctly if that would be the problem. \$\endgroup\$
    – Justme
    Commented Oct 28, 2023 at 15:29
  • 1
    \$\begingroup\$ Are you sure you are not programming the Arduino Nano? What toolchain are you using for programming? \$\endgroup\$
    – Ralph
    Commented Oct 28, 2023 at 15:33
  • 1
    \$\begingroup\$ Is there more than what is shown in the schematics? \$\endgroup\$
    – MiNiMe
    Commented Oct 28, 2023 at 15:33
  • \$\begingroup\$ 1) I am using this crystal oscillator: lcsc.com/product-detail/… I used it in another project before and the ATmega328p there worked without problems. 2) I am programming the ATmega328p and set the Arduino Nano as the ISP programmer. 3) No, there's no more than shown in the schematics. I'll try to mount an 100nF cap between VCC and GND and tell the result later. \$\endgroup\$
    – pomm es
    Commented Oct 28, 2023 at 16:28
  • \$\begingroup\$ Edit: added a 100nF cap between VCC and GND. No difference. Microcontroller broken? \$\endgroup\$
    – pomm es
    Commented Oct 28, 2023 at 17:19

1 Answer 1

1
\$\begingroup\$

Okay guys, finally found the solution for my problem:

At first I thought the capacitor C1 which is connected between RST and GND, was the problem, so I removed it. But this did not fix the problem.

It was indeed a software problem. I programmed the Mega328P using the Arduino IDE and MiniCore.

It seems like for some reason, the standard Arduino commands "pinMode()", or "digitalWrite()" etc. don't work.

But when I'm using the port register commands with DDRx and PORTx, everything works.

So instead of writing

pinMode(PB2, OUTPUT);
digitalWrite(PB2, HIGH);
delay(1000);
digitalWrite(PB2, LOW);
delay(1000);

I wrote

DDRB |= (1<<PB2);
PORTB |= (1<<PB2);
delay(1000);
PORTB &= ~(1<<PB2);
delay(1000);

and that solved my problem.

Why didn't I think of that earlier?

Edit: what also works, is instead of

digitalWrite(PB2, HIGH);

writing

digitalWrite(PIN_PB2, HIGH);
\$\endgroup\$
2
  • \$\begingroup\$ You did not show any code. You simply said you are controlling pin PB2 and that was not true, but we had no reason to doubt that. For the pin which is PB2, PB2 is simply a define for number "2", and pin PB2 is not 2 for the Arduino functions. Pin PB2 is "digital pin 10". And it's a bit useless to post a rhetorical question why you did not think about that earlier. We don't have an answer for that. \$\endgroup\$
    – Justme
    Commented Nov 12, 2023 at 12:26
  • \$\begingroup\$ We don't know what is hiding under the PIN_PB2 macro. This is not a standard AVR macro. You need to check it yourself. \$\endgroup\$
    – G36
    Commented Nov 12, 2023 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.