Step 13Compiling, Uploading and Running Your Application
Plug in the programmer to the computer.
Pop your microcontroller into its programming cradle, or connect up the pins as we talked about. There should be a total of six pins connected, RESET, MOSI, MISO, VCC, SCK and GROUND. Double check your wiring before continuing. You could do this on the breadboard, but i had difficulties getting the programmer to see the chip when i plugged wires straight into the ISP cable - though there is no good reason why this wouldn't work.
Connect your cradle/breadboard to the programmer.
If you're using a USBasp, then great! What comes next is extremely simple. Download a program called eXtreme burner: http://extremeelectronics.co.in/avr-tutorials/gui-software-for-usbasp-based-usb-avr-programmers/
You will also need the drivers for USBasp from here: http://www.fischl.de/usbasp/ go for the latest package. Unpack the data and you should find a folder called bin->win-driver. When the Windows eventually asks you what to do, select the option to install your own driver and point it to that directory. Unless you're on Windows 7 x64 where unsigned drivers simply don't work.
Fire up eXtreme burner and familiarise yourself with the interface. The array of F's in front of you is flash memory, where your program will be stored. The next tab along is the EEPROM, the extra memory on board the chip that you can log data to.
The third tab is Fuse settings, for the ATMega8, the fuses we will set are:
Low: FD
High: D5
This sets the chip up for a 4MHz external crystal, turns off clock division by 8 and enables BOD (brown out detection - if the voltage goes too low for some reason, the AVR can do funny things like randomly overwrite memory. Turning on BOD lets the processor stops the chip from going crazy and simply shuts it down).
http://www.engbedded.com/fusecalc/ is a good website for working out fuses
These values will differ if you're using a different microcontroller, use the application here to work out the fuses for you. The type of clock you want is:
Ext. Crystal Osc. : Frequency 0.3-8MHz, Start Up Time PWRDN/RESET: 16k CK/14 CK + 65ms
Uncheck "divide clock by 8 internally", ensure that SPIEN is checked otherwise you won't be able to program your chip ever again! You can set BOD if you want, but it's not essential. The fuses are shown at the bottom of the page, simply copy the values (hexadecimal) into eXtreme burner.
Select the chip menu from the toolbar and set it to ATMega8 - or whatever you're programming. Set the mode to ISP.
Then open the hex file in the program, once you've done that, the Flash window should be filled with some numbers - this is your program!
Go to the write menu with everything plugged in and select Write->Flash. A window should come up and will give you little updates as it goes along. Through USB it should take around 8-10 seconds. If you get any errors, double check your connections and try again.
Once the program has been uploaded successfully, remove the chip from it's cradle and put it back on the breadboard. Plug in the battery or turn on your power supply and the LED we plugged in should be blinking at you!
Now you're familiar with how to upload applications we can pick up the pace a bit. The next thing to add to our application is a shoot function.
Unzip the code below. You will need to modify your makefiles for each c file (editing which file it looks for, etc). You will need it for the following examples, or you can simply build the entire device and use the final code - have a read, edit it, play with it to suit your needs!
Code.zip66 KB| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|


























































