ATMEGA328-AU not working [ SOLVED ]

Hi everyone,

I have an issue with trying - for the first time - to burn the bootloader on my smd ATMEGA328-AU.

I have a PCB on which I have soldered my smd components :
ATMEGA328-AU,
a crystal, on PIN PB6 // PIN PB7 - respectively PIN 7 and 8.
2 polarised capacitor - 47 pF as the 22pF couldn't be soldered i ordered them too small :frowning: - between crystals pins and ground,
1 resistor - 1kOhms -, between RESET(PC6) and VCC(5V),
1 capa 47microF between AVCC(PIN 18) and VCC.
8 pin headers, with 6 for ICSP.

The schematics of the components are attached. Ignore the FTDI jumper, switch with Battery connection, or decoupling capacitor, I didn't put them in after first board didn't work.

Now the coding part :
I have an arduino Uno, which I'm trying to use to burn the bootloader on the ATMEGA.

For that I have modified my avrdude.conf file, so it includes the following :

part parent "m328"
id = "m328au";
desc = "ATmega328AU";
signature = 0x1e 0x95 0x14;

ocdrev = 1;
;

Then File->example->ArduinISP->ArduinISP.
I uploaded the file on the arduino Uno - no problems-.
Then when trying to burn the bootloader, it seems to not work.

I followed other posts on the forum, and from my terminal, I do - after cd to Arduino.app/Contents/Java/hardware/tools/avr/bin ) :

sudo ./avrdude -C../etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.usbmodem142101 -b19200 -e -Ulo

The output i get is :

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

/Users/pierretardif/Downloads/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Users/pierretardif/Downloads/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.usbmodem142101 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/pierretardif/Downloads/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/pierretardif/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem142101
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

After a couple of minutes, the ATMEGA starts fuming, then after unplugging it, i have a shortcut between VCC and GND, :(.
This has happened several times, and I have tripple checked my connections to make sure the second time that it does not occur again, but still it keeps happening.

I don't understand why.

The ATMEGA328-AU i used is this one :

For the next steps, I think I will buy an arduino nano, so the models are the same between the one on the PCB and the one burning it.

I will update my design as to fit all components, but I need guidance as I don't get :
1 why the device signature is 0x000000.
2 why the chip burns after a few minutes.

for 1 :
Do i need to have the exact capacitor of 22pf on each end of the crystal?
If yes, do they need to be polarised?

for 2 :
Could it be that I'm using polarised capacitor that does that?
They are all wired with the - towards the GND.

I'd appreciate any pointers, as I'm pretty lost right now.

Best,

KS

Your 328 symbol is incorrect:
3, 5, 21 are Gnd
4, 6 are VCC
18 is AVCC
20 is Aref
So you are missing some connections. The datasheet says all connections to power & gnd must be made.

1K from Reset to VCC is a pretty strong pullup, that might be too much for other devices to pull Reset low. 10K is standard.

47pF will impact the crystal operation, replace with 22pF.

If you are replacing the '328, replace with a '328P.

Your ICSP header is not standard. That could impact whatever programmer you are connecting. You might need an adapter cable:

MISO 1 6 VCC
SCK 2 5 MOSI
Reset 3 4 GND

Aref should be a cap to Gnd. 47uF is too big 0.1uF is standard to eliminate high frequency noise.

If the chip is burning up, that suggests something is miswired.
Device signature of 0x00s also says the chip is not communicating.

Signature bytes:
ATmega328 0x1E 0x95 0x14
ATmega328P 0x1E 0x95 0x0F

Output is showing
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Uno"

AVR Part : ATmega328P

File boards.txt in the /Arduino/hardware/arduino/avr path has
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.board=AVR_UNO

so you may need to change that to recognize the 328 vs 328P.
Or just get 328P chip, save a lot of headache all around.
Spend the extra 0.14 and save yourself a lot of headache.

Hi CrossRoads,

Thanks for this, I appreciate.

Yes I omitted some design elements, as the rest was not soldered, but I did the connections mentioned :
Pin 3 to GND
Pin 4 to VCC
Pin 5 to GND
Pin 6 to VCC
Pin 18 to VCC
Pin 21 to GND

See screenshot attached.

I will change the 1k to 10K resistor on Reset, the capacitor for ARef for 47 to 0.1 microF as well as the crystal's capacitors.

I have a couple of questions - for the slow one in the room :slight_smile: - just to be extra clear.

What do you mean by :

If you are replacing the '328, replace with a '328P.

I am using that in my design: that is the reference I got in Kicad: ATmega328P-AU, and I also already changed my avrdude.conf file so it would register it :
ATmega328 part :

#------------------------------------------------------------
# ATmega328
#------------------------------------------------------------

part
    id			= "m328";
    desc		= "ATmega328";
    has_debugwire	= yes;
    flash_instr		= 0xB6, 0x01, 0x11;
    eeprom_instr	= 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
			  0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
			  0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode	= 0x86;
    # avr910_devcode	= 0x;
    signature		= 0x1e 0x95 0x14;
    pagel		= 0xd7;
    bs2			= 0xc2;
    chip_erase_delay	= 9000;
    pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
		 "x x x x x x x x x x x x x x x x";

    chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
		 "x x x x x x x x x x x x x x x x";

    timeout	= 200;
    stabdelay	= 100;
    cmdexedelay	= 25;
    synchloops	= 32;
    bytedelay	= 0;
    pollindex	= 3;
    pollvalue	= 0x53;
    predelay	= 1;
    postdelay	= 1;
    pollmethod	= 1;

    pp_controlstack =
	0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
	0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
	0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
	0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
    hventerstabdelay	= 100;
    progmodedelay	= 0;
    latchcycles		= 5;
    togglevtg		= 1;
    poweroffdelay	= 15;
    resetdelayms	= 1;
    resetdelayus	= 0;
    hvleavestabdelay	= 15;
    resetdelay		= 15;
    chiperasepulsewidth	= 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    ocdrev              = 1;

    memory "eeprom"
	paged		= no;
	page_size	= 4;
	size		= 1024;
	min_write_delay = 3600;
	max_write_delay = 3600;
	readback_p1	= 0xff;
	readback_p2	= 0xff;
	read = " 1 0 1 0 0 0 0 0",
	       " 0 0 0 x x x a9 a8",
	       " a7 a6 a5 a4 a3 a2 a1 a0",
	       " o o o o o o o o";

	write = " 1 1 0 0 0 0 0 0",
	      	" 0 0 0 x x x a9 a8",
		" a7 a6 a5 a4 a3 a2 a1 a0",
		" i i i i i i i i";

	loadpage_lo = " 1 1 0 0 0 0 0 1",
		      " 0 0 0 0 0 0 0 0",
		      " 0 0 0 0 0 0 a1 a0",
		      " i i i i i i i i";

	writepage = " 1 1 0 0 0 0 1 0",
		    " 0 0 x x x x a9 a8",
		    " a7 a6 a5 a4 a3 a2 0 0",
		    " x x x x x x x x";

	mode		= 0x41;
	delay		= 20;
	blocksize	= 4;
	readsize	= 256;
    ;

    memory "flash"
	paged		= yes;
	size		= 32768;
	page_size	= 128;
	num_pages	= 256;
	min_write_delay = 4500;
	max_write_delay = 4500;
	readback_p1	= 0xff;
	readback_p2	= 0xff;
	read_lo = " 0 0 1 0 0 0 0 0",
		  " 0 0 a13 a12 a11 a10 a9 a8",
		  " a7 a6 a5 a4 a3 a2 a1 a0",
		  " o o o o o o o o";

	read_hi = " 0 0 1 0 1 0 0 0",
		  " 0 0 a13 a12 a11 a10 a9 a8",
		  " a7 a6 a5 a4 a3 a2 a1 a0",
		  " o o o o o o o o";

	loadpage_lo = " 0 1 0 0 0 0 0 0",
		      " 0 0 0 x x x x x",
		      " x x a5 a4 a3 a2 a1 a0",
		      " i i i i i i i i";

	loadpage_hi = " 0 1 0 0 1 0 0 0",
		      " 0 0 0 x x x x x",
		      " x x a5 a4 a3 a2 a1 a0",
		      " i i i i i i i i";

	writepage = " 0 1 0 0 1 1 0 0",
		    " 0 0 a13 a12 a11 a10 a9 a8",
		    " a7 a6 x x x x x x",
		    " x x x x x x x x";

	mode		= 0x41;
	delay		= 6;
	blocksize	= 128;
	readsize	= 256;

    ;

    memory "lfuse"
	size = 1;
	min_write_delay = 4500;
	max_write_delay = 4500;
	read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
	       "x x x x x x x x o o o o o o o o";

	write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
	      	"x x x x x x x x i i i i i i i i";
    ;

    memory "hfuse"
	size = 1;
	min_write_delay = 4500;
	max_write_delay = 4500;
	read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
	       "x x x x x x x x o o o o o o o o";

	write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
	      	"x x x x x x x x i i i i i i i i";
    ;

    memory "efuse"
	size = 1;
	min_write_delay = 4500;
	max_write_delay = 4500;
	read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
	       "x x x x x x x x o o o o o o o o";

	write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
	      	"x x x x x x x x x x x x x i i i";
    ;

    memory "lock"
	size = 1;
	min_write_delay = 4500;
	max_write_delay = 4500;
	read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
	       "x x x x x x x x x x o o o o o o";

	write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
	      	"x x x x x x x x 1 1 i i i i i i";
    ;

    memory "calibration"
	size = 1;
	read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
	       "0 0 0 0 0 0 0 0 o o o o o o o o";
    ;

    memory "signature"
	size = 3;
	read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
	       "x x x x x x a1 a0 o o o o o o o o";
    ;
;

part parent "m328"
    id			= "m328p";
    desc		= "ATmega328P";
    signature		= 0x1e 0x95 0x0F;

    ocdrev              = 1;
;

part parent "m328"
    id			= "m328pb";
    desc		= "ATmega328PB";
    signature		= 0x1e 0x95 0x16;

    ocdrev              = 1;
;

part parent "m328"
    id			= "m328au";
    desc		= "ATmega328AU";
    signature		= 0x1e 0x95 0x14;

    ocdrev              = 1;
;

I'm also unsure what you mean by :

so you may need to change that to recognize the 328 vs 328P.
Or just get 328P chip, save a lot of headache all around.
Spend the extra 0.14 and save yourself a lot of headache.

My chip which I'm using in my arduino Uno is an ATMEGA328P-PU, so you mean buying the one I'm buying for my PCB?
Does something like this work :

MISO 1 6 VCC
SCK 2 5 MOSI
Reset 3 4 GND

Yes I just use the ports on the arduino Uno to link it together, as it's just a matter or switching them around and triple checking.

Thanks for your answers, I'll get to it and report.

Best,

KS

I also had some extra questions I forgot :

I'm intending to use a classic LiPo Battery Pack – 500mAh to power it.
Do I need a regulator, fuse, or diode on it?

I read that I should not need that, but now that everything is going sideway, _/-('.')-_ i wonder...

Best,

KS

You can use the 328 on your target board, it just needs extra fooling around as you have found. You just need a little more.
If you can use 328P instead, then you can bootload it as an Uno and download into as an Uno and just make life easier for yourself. I use '328P for my projects and bootload them all as Uno.

With the LiPo, is regulated/boosted anyway to get to 5V? Or just working with the 4.2V down to 3.7V output?
If the raw output, then you probably want to run at 8 MHz vs 16 MHz.
If you add this to your IDE

then you can easily set up for '328 @ 8 MHz.

What is the purple smudginess in the board design?

Ah the purple is the silk screen of the back layer:

Looks like this in real life - see attached picture -.

Thanks for the answers.

So I'm getting a 328P, and will use the 3.7V classic battery, so will change my crystal to a 8Mhz.

Thanks a lot, I have revised my design, and ordered the parts, will report once received.

Best,

KS

Ok, the ATMEGA-328P works like a charm on the revised design, Thanks a lot.

KS