2
\$\begingroup\$

Before I can program my ATmega32 through USBasp but now only in 30 times or more try I can program ATmega32.

I get this error

avrdude: error: program enable: target doesn't answer. 1 

program command

avrdude -c usbasp -p m32 -u -U flash:w:pd.hex

What's problem and solution?

When I try with -F option, I get below message.

avrdude: Device signature = 0x887b15
avrdude: Expected signature for ATmega32 is 1E 95 02
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to EE.SE. A search on this site for the error message "avrdude: error: program enable: target doesn't answer" reports (currently) 19 other hits plus yours. As explained in "How do I ask a good question?", it will improve your chances of replies if you show what research you have already done, what have you already tried and what happened etc. You can edit your question to add that information. \$\endgroup\$
    – SamGibson
    Commented Jul 29, 2018 at 15:00

5 Answers 5

3
\$\begingroup\$

The problem is given in the error message:

target doesn't answer

Possible reasons are:

  • Incorrect/slacky wiring: Might seem unlikely if you did not change anything since you've successfully programmed the avr before. However, expecially if using a breadboard or jumper cables: Double-Check your connections. Also test for short-circuits between signals.
  • Hardware failure: Overvoltage, a short circuit or drawing too much current from the avr can damage the device so that it is simply broken.
  • Clock speed: If the clock is too high for your target, you cannot program it. Decrease the baudrate by using the -b-option with avrdude.
  • Fuses: Improper settings of the fuses might have locked you out, e.g. by disabling the reset pin.
  • Supply voltage missing or not stable. Use a proper supply and bypass capacitors.
\$\endgroup\$
3
  • \$\begingroup\$ When I try with -F option I get this message. avrdude: Device signature = 0x887b15 avrdude: Expected signature for ATmega32 is 1E 95 02 \$\endgroup\$ Commented Jul 29, 2018 at 15:23
  • 1
    \$\begingroup\$ do not use -F option. It is not for for this case \$\endgroup\$ Commented Jul 30, 2018 at 21:59
  • \$\begingroup\$ +1 for bypass capacitors. In my case all I had to do was to add a little 100nF between Vcc and GND close to the chip to be programmed. \$\endgroup\$ Commented Jan 17, 2021 at 23:11
9
\$\begingroup\$

I was pulling my hair out as I had received 20 Atmega328P's and the first one I was able to get programmed with my USBasp Programmer, but swapping the processors I was not able to program on breadboard or within an UNO.

Thanks to some posts I felt confident it was a fuse setting where it was speaking too fast. I have an external 16MHz crystal in my setup so I used:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -P usb -v -C /Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -B 10 -c usbasp -p m328p -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

I found most of this command in other forums but the magic I needed was the "-B 10" to get it to only speak at a 10us clock rate. Once I did this command line command on my Mac, I was able to use the Arduino GUI to do a Burn Bootloader or Upload Using Programmer without issue.

The problem seems to be the USBasp board/sw did not auto clock down to find a happy setting. I am using the Amazon HiLetgo which claims "USBASP V2.0" but has very back-level firmware as well, so I needed to update that with the latest (2011) usbasp from Thomas Fischl named: usbasp.2011-05-28 that was a pain also but it's a one time deal though I am waiting on a second programmer to arrive and I will have to re-flash it also.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Man, you saved my life! I have 50 ATMega32s here as part of a mechanical keyboard group buy and I just could not get avrdude to talk to them! Tried everything, even thought my USBasp is broken... -B 10 and boom, all's fan daby dozy :) Thanks again! \$\endgroup\$
    – piit79
    Commented Aug 12, 2020 at 22:06
2
\$\begingroup\$

I was getting this error even with correct wiring until I added -B4 parameter to avrdude.

After I added -B4 parameter and programmed the chip, I didn't need to use it anymore...

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Ok but what does that do? \$\endgroup\$
    – pipe
    Commented Mar 28, 2021 at 16:30
  • \$\begingroup\$ That slows down the "Bitclock"... \$\endgroup\$
    – Judah
    Commented Mar 30, 2021 at 3:17
  • \$\begingroup\$ this worked for me \$\endgroup\$
    – Babu James
    Commented May 11, 2023 at 9:36
0
\$\begingroup\$

You should connect the protocol SPI of USBasp to the microcontroller. These are MISO, MOSI, SCK and RESET.

Then connect an XTAL of 16MHz with 2 capacitors of 22pF to ground.

Finally, connect a resistor of 10K ohms of RESET to VCC.

Check: https://www.electronics-lab.com/burning-the-bootloader-on-atmega328-using-usbasp-programmer/

\$\endgroup\$
1
  • \$\begingroup\$ You are right in general. However, for flashing the chip using USBasp, the only connections you need are MOSI, MISO, SCK, RESET, VCC and GND. The crystal is not needed for flashing, and neither is the pullup on RESET (I know it's recommended, but it's not required). I just flashed a bunch of ATMega32s this way. \$\endgroup\$
    – piit79
    Commented Aug 12, 2020 at 22:23
0
\$\begingroup\$

I had the same issue with an attiny25-20PU that had already a unknown program on. I copied the arduino command line for avrdude from arduinos upload output into a terminal, added at the end a -B and used different big numbers (32 48 64) and by good luck the 64 made the programming so slow that it worked - and from now on it worked without any -B option. I did this for 4 identical circuits with always the same repeatable procedure. It seems to be a trap for newbies.

"arduino" means Arduino 1.8.19 development platform.

My Linux Mint 21.3 command line: ~$/home/xxx/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino18/bin/avrdude -C/home/xxx/Arduino/hardware/ATTinyCore-2.0.0/avr/avrdude.conf -v -pattiny25 -cusbasp -Uflash:w:/tmp/arduino_build_339885/usbaspattiny25.ino.hex:i -F -B 64

\$\endgroup\$

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.