I loaned out my trusty USBTinyISP to a friend a while back and it was easier to go find an alternative than to coordinate schedules. So I bought a USBasp – another type of open source programmer for AVRs. I ran into an number of problems getting it to work because there is so much variation online (spread over many years). So here’s some helpful hints.
Various Problems I’ve seen:
warning: cannot set sck period. please check for usbasp firmware update.
When avrdude tries to program a controller, it will try to match up clock speeds to make everything easier. When it can’t, it’ll complain that it’s not working, and you should upgrade your firmware. This is a warning, not an error. You probably don’t need to upgrade your firmware. If you do want to upgrade your firmware, you will need another programmer to do so. You can ignore this error.
I’ve heard the recommendation to upgrade drivers. If you’re on a Mac, You don’t need a driver. You can do a quick check to see if your Mac can see your USBasp. Open the System Information application (Either in /Applications/Utilities or from the About this Mac menu item in the Apple Menu) and click on the USB selection under hardware. If you can find usbasp, your computer can see your programmer. The problem therefore, is likely your chip.
error: programm enable: target doesn't answer. 1
AVRdude isn’t getting a response from the chip. This means that you either don’t have it wired up right or that your chip is talking too fast. I managed to run into both.
First, I had things wired up wrong. If you do a search for 10-pin ISP pinout you’ll get a lot of images and posts about how to wire your 10 pin connector. The problem with most of these is that they are describing the male connector. More than once, I swapped the pins horizontally.
Here’s an image of my cable:
Note that the notch is one the right-hand side. A reminder also that unlike connecting an SPI device where
MOSI goes to
MISO, when you’re connecting a programmer, you connect
One time, I was messing around with fuses. I thought that I’d set everything correctly, but apparently I did not. All I got from the programmer was
t<span class="s1">arget doesn't answer. 1. It was infuriating.
On a whim (following recommendations found here), I connected up a 16Mhz crystal and a pair of 22pF capacitors to the crystal pins on my uC.
Miraculously, I could suddenly talk to my microcontroller again. Something I’d done had messed up the fuses. I don’t really know what because I only recall trying to switch off the
CKDIV8 fuse. Back up to speed my fuses read as something different. I fixed them and was back in business.
Lastly, I found an application called AVRFuses written by Jason von Nieda. It makes setting fuses really easy, as well as reading fuses. You can even program with it if you want to.