geekhack

geekhack Projects => Making Stuff Together! => Topic started by: layornos on Sat, 10 December 2016, 07:55:51

Title: Programming Atmega32u4
Post by: layornos on Sat, 10 December 2016, 07:55:51
Dear all,

i tried to design a PCB, using a Atmega32u4 instead of a Teensy to save some space. After the soldering, i tried to program the uC via the JTAG interface and a JTAGICE clone from eBay. That wasn't successful, so i ordered this http://www.ebay.de/itm/172399352607?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT. I connected the respective pins to a USPASP programmer, then i tried via AVRDUDE to program the uC with the following command:

avrdude -c usbasp -p m32u4 -u -U flash:w:ATMega32U4-usbdevice_dfu-1_0_0.hex

But then i get the following error-message:
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: error: programm enable: target doesn't answer. 1
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.

avrdude.exe done.  Thank you.


The -B flag has no effect:
avrdude -c usbasp -p m32u4 -u -U flash:w:ATMega32U4-usbdevice_dfu-1_0_0.hex:a -B 120

avrdude: set SCK frequency to 8000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm 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.exe done.  Thank you.


I double checked the pins and even tried the JP3 jumper for lower programming speed.
The programmer is a USBASP v2.0.

I am out of ideas, any suggestions?


Title: Re: Programming Atmega32u4
Post by: pomk on Sat, 10 December 2016, 08:31:42
What does your board look like and have you measured that all solder connections are good?
Title: Re: Programming Atmega32u4
Post by: Tactile on Sat, 10 December 2016, 09:33:34
Here are some troubleshooting tips for that error. Hope this helps.

https://learn.adafruit.com/usbtinyisp/help
Title: Re: Programming Atmega32u4
Post by: trebbu on Sat, 10 December 2016, 09:47:54
I'm not entirely sure what I'm talking about, but I was able to install a bootloader and set some fuses  with a similar setup plus a quartz and two capacitors connected.
Title: Re: Programming Atmega32u4
Post by: hasu on Sat, 10 December 2016, 17:16:02
No pic? It would be useful to show how you coneect. I'm suspecting your wiring and power supply.
IIRC, you need to give power to both VCC and AVCC, not sure but Xtal may be needed also. You'd better check datasheet yourself in the end :D
Title: Re: Programming Atmega32u4
Post by: layornos on Sat, 10 December 2016, 17:47:23
I was able to flash the uC after connecting all VCC's and GND's. Now i get an ”Over current condition” error, but that might be a topic for a new thread. Thanks for your help.
Title: Re: Programming Atmega32u4
Post by: hasu on Sat, 10 December 2016, 17:55:14
nice.
Xtal was not needed?
If you can post how you connected and programmed the uC it would be great for future reference.
Title: Re: Programming Atmega32u4
Post by: layornos on Sun, 11 December 2016, 03:51:57
As you can see in attachment 2, i've soldered wires to a smd quarzoszillator to connect it to the breadboard. I used 2 22pF capacitors.

[attach=1][attach=2]