# How can I tell that USBasp is working?

I have the USBasp programer and I'm trying to burn bootloader on Atmega328 so that it can be used as a replacement chip in Arduino board (replacement chips with the bootloader installed are quite expensive).

I have installed the USBasp drivers - the installation is quite straightforward thanks to the guide. The device was recognized and is working properly - according to windows.

I have then connected the pins according to the datasheet. After that, I started Arduino IDE and I selected USBasp as a programer:

I have noticed that whenever I hover over Tools the arduino IDE lags for a while. But that might simple be an unrelated software bug.

After I selected the correct programmer I have clicked Burn bootloader and I got this error:

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.


I have already been trying to program this chip using Raspberry PI - and I've failed as well. And I still can't find out where the error is. Except the possibility that I bought 2 void chips.

My question is how can I test all fragments of my system and check which one is broken. AvrDude's errors are useless.

Here's an image of my connections when trying the same (and with the same result) with AtTiny:

• When I have gotten that error, it has been one of two things: a loose wire/bad connection or an error in my programmer circuit. It has been exceedingly rare that there was a problem with the AVR (the two times were after passing excess voltage through it and breaking pin 1). Your error suggests that the USBasp works (otherwise you get a could not find device error). Take a multimeter and verify each connection between the USBasp circuit board and the corresponding pin on the AVR; check the pull-up resistor; and confirm that your chip doesn't need a crystal. How did you setup your circuit? – cyberx86 Jul 1 '14 at 19:30
• @cyberx86 First of all: what pull-up resistor? I just connected wires directly from programer to the atmega328. (I also tried AtTiny13 with the same result). – Tomáš Zato Jul 1 '14 at 19:33
• When programming an AVR, you need to set the reset pin low. It is typically held high with a pull up resistor between pin 1 and Vcc. I have always used this circuit: avrprogrammers.com/devices/atmegaxx8 - for simplicity, you can omit SW1, and in most cases, a new AVR chip doesn't need a crystal (so you can omit the crystal and capacitors, unless non-standard fuses were set). – cyberx86 Jul 1 '14 at 19:43
• The connections you have from the Atmel PCB to the AtTiny, look good. If you haven't already, electrically check (multimeter set on resistance (ohms)), the connections from the USBasp board directly to the AVR pins - this will both verify that there are no loose wires and that everything is in the right place. The pin marked on the board with a triangle is MOSI (so touch that and pin 6 on the AVR) (and check that each of the other 3 data lines - SCK, MISO, RST are electrically connected); – cyberx86 Jul 1 '14 at 22:58
• Also - you can program without the Atmel PCB (one less thing that might cause trouble, although checking for continuity should eliminate that). As one other check, measure the voltage across the chip (pin 4 and 8) - it should be 3.3V or 5V - I have usually favoured 5V for programming) - there is a jumper on the USBasp to change the voltage. – cyberx86 Jul 1 '14 at 22:59

The error message you are seeing means that the chip is not responding to the "enable programming mode" command that the programmer is sending. Either you have got the connections wrong, or the programmer is sending the commands too quickly (programming frequency too high).

New AVR chips come configured to use the chip's internal oscillator as a clock source, with the CLOCKDIV8 ("divide clock frequency by 8") fuse set. This means that they run at 1MHz. The maximum programming frequency the chip supports is clock speed / 4, i.e. 250kHz. The USBASP defaults to 375kHz, which is too fast, so you need to slow it down.

You do this either by setting the "slow SCK" jumper of your USBASP, if it has one, or by using the avrdude -B option:

    avrdude -c usbasp -p m328p -B 5 -U flash:w:bootloader.hex:i


The number after the -B option selects the programming speed (specifically, the clock period, the inverse of the frequency, so higher numbers mean slower frequencies). If -B 5 doesn't work, try a higher number, like -B12 or even -B60.

Update: this line in the avrdude output suggests that your USBASP firmware version doesn't support the -B option, so you will need to use the jumper:

    avrdude: warning: cannot set sck period. please check for usbasp firmware update.


Recently, I was trying to make a little project using my atmega8, but I faced with this problem. I thought that the chip had flaws because of its using time, but I remembered that the last time I write code inside it, I programed the fuses to make it work with its internal oscillator! And I tried to program it (again) but this time with a crystal and…. Ta ta taaaa… that was!

I had created the Standalone Arduino, but when trying to program it with a USBasp, I received the OP's error. After following cyberx86 clue about reverifying the pins, I found that MOSI, from the AVR Programming adapter, was shown incorrectly wired up in the photo although, the written description of the pin out was correct:

Be sure to refer to the Arduino pin mapping for help wiring this up.

• The MISO pin of your adapter will go to pin 18 or Arduino digital pin 12 of your Atmega chip.
• The SCK pin of your adapter will go to pin 19 or Arduino digital pin 13 of your Atmega chip.
• The MOSI pin of your adapter will go to pin 17 or Arduino digital pin 11 of your Atmega chip.

In the photo the (dark green) wire that should go to MOSI, pin 17, actually goes to pin 16!

After I had corrected this issue, and connected the MOSI from the AVR Programming adapter to pin 17 on the ATMega, then the error went away.

In my case of ATMega32A it was the programmer writing too fast to microcontroller and -B option given to avrdude set SCK period (and therefore frequency as well) to rate that enabled proper communication. I spent too much time making this setup work, I thought microcotroller is dead at some point.

-B Specify JTAG/STK500v2 bit clock period (us).

with error:

me@comp:~$sudo avrdude -c usbasp -p m32 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.  OK: me@comp:~$ sudo avrdude -c usbasp -p m32 -B 5  // you may increase this value
// to set even lower frequency

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9502

avrdude: safemode: Fuses OK (E:FF, H:99, L:E1)

avrdude done.  Thank you.