programming atmega328p-au chip

Hi Everyone,

I wonder if anyone can help me.

I've been trying for the last two days to try and program an ATMEGA328P-AU chip that I have soldered onto my on PCB.

I've got an ICSP header on the PCB and all the connections are connected as I have continuity tested them with my DMM. The project I'm working on as a screen attached and when the VCC pin is connected the screen is illuminated. There is power getting to the chip.

When I start to program the chip I've attached my USBasp but it's coming up with the following error:

Arduino: 1.8.10 (Windows 10), Board: "Arduino Nano, ATmega328P"

C:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "C:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

Using Port : usb
Using Programmer : usbasp
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 : usbasp
Description : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

Error while burning bootloader.

The chip I'm trying to program is a brand new chip purchased from RS Components. I have a 16Mhz crystal attached to pins 7 and 8 of the chip with 22pF capacitors on the output of the crystal to ground.

Attached is a pic of how the ATMEGA328P-AU chip is laid out along with the ICSP. Again, I have checked continuity between the ISCP pins and the relevant pins on the microcontroller and continuity is there. I have checked with a magnifying glass all the soldering on the pins on the microcontroller and there are no shorts or solder bridges.

I have also installed the Minicore add-on in the arduino IDE and tried using an Arduino Uno as the programmer using Arduino as ISP. I get the following message when using this through the Arduino IDE:

Arduino: 1.8.10 (Windows 10), Board: "Arduino Nano, ATmega328P"

C:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "C:\Users\brett\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

Using Port : COM3
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 = 0xff00ff
avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.

avrdude done. Thank you.

Error while burning bootloader.

Can anybody suggest what might be the problem?

Your help and advice is very much appreciated.

Kindest Regards,

Brett
Microcontroller.jpg

Microcontroller.jpg

Minimal circuit should contain:

  1. power with decoupling 100nF capacitor on each power pin,
  2. oscillator or clock source (for Arduino setup like UNO it is mandatory),
  3. reset - 10k pull-up + 100nF isolating capacitor in line.
    See the schematics: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard .
    I do not see these in your schematics except of crystal you’ve described.

In the second case 0xff00ff looks like shortage or floating wire (if it is not problem with e.g. reset).

My Apologies, I forgot to attach those parts to the post.

Here they are. I have a 16Mhz Crystal oscillator (https://uk.rs-online.com/web/p/crystal-units/8149440/) attached to pins 7 & 8 of the Microcontroller along with appropriate 22pF decoupling caps to ground from the crystal.

The power comes from a ZLDO1117 5v regulator with 10uf capacitor on the input and 10uf Capacitor on the output.

The reset goes from the reset pin on the microcontroller (Pin 29) through a 10K resistor to VCC. VCC is 5v from the 5v regulator mentioned above.
crystal.jpg
power.jpg
Reset.jpg
Kindest Regards,

crystal.jpg

power.jpg

Reset.jpg

"avrdude: Device signature = 0xff00ff"

Sure looks like the chip doesn't want to talk. The rest of your connections look fine.

You're sure you have 22pF caps, not 0.22uF, something big like that? We've seen that happen before.

Hi Yeah I have 22pF caps. These are what I ordered: https://uk.rs-online.com/web/p/mlccs-multilayer-ceramic-capacitors/2644258/

I'm just at a loss as to what I need to do to get it talking so that I can upload the sketch to make my project work.

Thanks,

Brett

Check you circuit carefully again. I'm recommending to check the RESET pin with the DMM. Reset pulse should be visible as significant voltage drop as uploading starts, otherwise it should be 5V (VCC).
Also, check the power directly on pins.

At this point, I'd suggest using a Programmer, vs the Uno as Programmer. Many folks can get it to work, many cannot.
I do a lot of bootloading, and I bought a real Programmer many years ago, they are a good tool to have on hand.
I have the original Atmel AVR ISP MKii, no longer sold, but available as clones like this one
https://www.amazon.com/TinySine-USBtinyISP-AVR-Programmer-Arduino/dp/B00N8EVQ30

(forum may stick some extra characters to the start and end of the link, delete them if needed)

CrossRoads:
(forum may stick some extra characters to the start and end of the link, delete them if needed)

Yes, you have to edit it in source view - several http and slashes... That's why I'm usually posting URL like plain text. Sorry for OT.

OK, Checked the reset pin while attempting to burn the boot loader using Arduino as ISP.

Voltage showed 4.95v with NO alteration. Stayed at 4.95v.

Thanks,

CrossRoads:
At this point, I'd suggest using a Programmer, vs the Uno as Programmer. Many folks can get it to work, many cannot.
I do a lot of bootloading, and I bought a real Programmer many years ago, they are a good tool to have on hand.
I have the original Atmel AVR ISP MKii, no longer sold, but available as clones like this one
https://www.amazon.com/TinySine-USBtinyISP-AVR-Programmer-Arduino/dp/B00N8EVQ30/ref=pd_sbs_328_3/131-9879045-3487919?_encoding=UTF8&pd_rd_i=B00N8EVQ30&pd_rd_r=42bb33e6-0b4b-48c5-a89a-7525b4fcd866&pd_rd_w=gio1b&pd_rd_wg=gC5WM&pf_rd_p=7c0dad87-8a25-4c4f-9349-026039ea6cb3&pf_rd_r=N9TVKB2BRWM47RCCEXK4&psc=1&refRID=N9TVKB2BRWM47RCCEXK4

(forum may stick some extra characters to the start and end of the link, delete them if needed)

Thanks for that. I already have the USBasp Programmer but do you suggest getting a USBTiny programmer too?

Many Thanks,

Check the reset pulse directly on USBasp unconnected for comparison. I hope any cheap DMM should show it. It always works for me. Reset pulse is 200ms, it should be observable on DMM.

Wait! I forgot that Chinese USBasps with default FW have problem to deal with raw ATmegas. You have to close JP3 - slow SCK on USBasp, but JP number can vary according exact USBasp type so check it on web for sure.

"I already have the USBasp Programmer"

Let's get that working then, skip the Uno as Programmer.

Thank you to everyone who has helped me. I tried shorting out J3, as Budvar10 suggested, on my USBasp and went to burn bootloader using USBasp as the programmer.

SUCCESS. Bootloader burnt and sketch uploaded.

Thank you, Thank you, Thank you to all involved.

Kindest Regards,

Brett

You are welcome!
:slight_smile: