USBAsp is a in-circuit open-source programmer for ATMEL AVR microcontrollers. It is low cost, small, easy to implement, simply consist of ATMEGA8, or ATMEGA88, and some passive components. It was designed by Thomas Fischl. ( for more info just visit the author website http://www.fischl.de/usbasp )
Most students, hobbyist, or maybe professional engineer that just start learning AVR may find it quite useful stuff.
As the name suggest, it uses USB interface to communicate with host PC, its simpler rather than using a parallel port ( nowadays many laptop doesn't have one )
Specifications:
- Low speed USB operation ( programming speed up to 5kBps )
- Required Windows driver : libusb-win32
- USB device controller firmware based on V-USB by Objective Development Gmbh ( http://www.obdev.at/products/vusb/ )
- Programmer software : avrdude ( http://www.nongnu.org/avrdude/ )
- Working voltage 5V ( provide 5V supply to target microcontroller, drawn from USB supply directly, but careful it has no short circuit protection, USB can only supply up to ~200 mA normally )
- Jumper for Slow SCK target ( < 1.5 MHz )
Zipped folder containing bin, circuit, and firmware can be downloaded from the author site. In case your child can't access it or your internet connection sucks, here use mine: usbasp.2011-05-28 (fischl.de).zip
In this post, I'm sharing my experience implementing one on PCB.
( p.s. there are a lot of PCB file designed by users that can be downloaded from the author website, but as a beginner its a good choice to try make it by yourself, the learning experiences you'll got is invaluable ).
( p.s. there are a lot of PCB file designed by users that can be downloaded from the author website, but as a beginner its a good choice to try make it by yourself, the learning experiences you'll got is invaluable ).
USBAsp can use ATMEGA8, ATMEGA48, or ATMEGA88 as the controller. As for me, I'm using ATMEGA8A ( pretty similar to ATMEGA8 ), its the cheap micro that I bumped into when browsed through various online store ( just 20,000 IDR :) ).
For the PCB design software, I use Altium Designer to draw the schematic and make the layout. The schematic is shown below: ( Tx and Rx connection to 2x5 header got removed, since I don't plan to use it anyway )
And here's the pic of the finished PCB prototype: (manufactured by local PCB manufacturer at Bandung, Indonesia, Selc PCB )
After it was assembled and soldered manually by hand, the finished PCB is looked like this:
Now we already got the stuff in our hand, how do we get things working? How do we use it to burn the flash of our target microcontroller?
Right now, the newly soldered ATMEGA8A micro is still empty ( unprogrammed ), so we need to program it with proper USBAsp firmware.
These steps below summarized it:
- Do not plug the USBAsp to the host PC USB port.
- We need to pick the proper firmware (.hex) inside the bin/firmware folder. I use ATMEGA8A, but the 'A' letter won't be a problem, so just pick the firmware for ATMEGA8 which is "usbasp.atmega8.2011-05-28.hex".
- We need another working AVR programmer that support SPI interface.
- Connect jumper "SELF PROG".
- Connect the working programmer to USBAsp then program the flash using the firmware in step 2.
- Change the fuse bit, since my USBAsp use 12 MHz crystal then it should be changed to hfuse = 0xC9, lfuse = 0xEF.
- Done! Now USBAsp can be used to progam target microcontroller.
Follow these steps below to do so:
1) Connect USBAsp to PC USB port.
2) Windows will try its hardest to find the correct driver for your device, but eventually it given up and failed to install the driver ( unless you ever connect USB device with same PID & VID with USBAsp before ).
3) Open device manager, there you will see USBAsp under Other devices with yellow exclamation mark.
1) Connect USBAsp to PC USB port.
2) Windows will try its hardest to find the correct driver for your device, but eventually it given up and failed to install the driver ( unless you ever connect USB device with same PID & VID with USBAsp before ).
3) Open device manager, there you will see USBAsp under Other devices with yellow exclamation mark.
4) Right Click on it and choose Update Driver Software…
5) When asked “How do you want to search for driver software?” Choose “Browse my computer for driver software”
5) When asked “How do you want to search for driver software?” Choose “Browse my computer for driver software”
6) Then browse and locate under the downloaded USBAsp folder, in my case it is in “usbasp.2011-05-28 (fischl.de)\bin\win-driver\libusb_1.2.4.0”. Check include subfolders. Click Next. Then Windows will install the driver (if a warning prompted out, just ignore it and continue with the proccess).
7) Windows finished installing the driver software.
8) Done, now USBAsp is listed under libusb-win32 device in device manager, then we can start using it to program other microcontroller target.
Now to program target microcontroller, here's the step to follow:
1) We need to connect these 6 pin ( 2 supply pin + 4 SPI pin ) to the target: VCC, GND, SS, MOSI, MISO, SCK.
( VCC is supplying 5V to the target micro, but if the target is self powered we shouldn't connect it, USBAsp can still communicate with target, given that they share the same GND )
Also on the target micro, SS and RST pin should be tied together.
2) Open command prompt, then cd (change directory) to where the compiled application hex file is located.
3) Use avrdude to perform the programming (avrdude should already be installed, my avrdude come along when I installed WinAVR). Type command in cmd:
avrdude -c usbasp -p m8 -U flash:w:main.hex
Then hit Enter.
( here the target micro is also another ATMega8A microcontroller so we specify -p options to be ‘m8’ )
4) If it is needed to read or write to fuse bit of target micro, these avrdude command can be used:
to read:
avrdude -c usbasp -p m8 -U hfuse:r:-:h
avrdude -c usbasp -p m8 -U lfuse:r:-:h
( r = read, h = hexadecimal )
to write:
avrdude -c usbasp -p m8 -U hfuse:w:0xc9:m
avrdude -c usbasp -p m8 -U lfuse:w:0xef:m
( w = write, m = immediate mode, the byte is specified in the command )
5) We're done, let's just call it a day. :)
No comments:
Post a Comment