Step 10: Preparing the Microcontroller
If you don't have the Arduino IDE, download it and install it. I am using version 0022.
The following steps are explained in detail in this wiki article: http://code.google.com/p/ro-4-copter/wiki/GeneralSoftwareSetup
This page is just a really short summary of what is already in the above wiki article!
The Arduino bootloader should be programmed into the microcontroller first. This step requires the use of an AVR programmer. However, after the bootloader is flashed into the microcontroller, you will only need an USB-to-serial cable (such as an FTDI cable) to upload code from the Arduino IDE.
The bootloader (I've attached it) is modified slightly since I'm using the ATmega644P instead of the usual Arduino's ATmega328P. The files are provided. The fuse-bits need to be written to the correct values as well.
AVRDUDE is the utility that we use to flash the bootloader .hex file into the microcontroller. The AVRDUDE commands you'll need is
"avrdude -c programmer_name -p atmega644p -U flash:w:bootloader_filename.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m"
Pay attention to the programmer_name and the bootloader_filename! The fuses are to get the ATmega to use the 16 MHz resonator, set the bootloader size, enable the bootloader, disable JTAG and enable SPI downloading.
Also copy the bootloader folder "Ro4Copter_Boot" (remember to rename it without the date version) as .../arduino-0022/hardware/arduino/bootloaders/Ro4Copter_Boot.
Also, download the Arduino "core" I've provided here (called Ro4Copter_Core, remember to rename it without the date version), and place it into the "core" directory within Arduino so you get .../arduino-0022/hardware/arduino/cores/Ro4Copter_Core . Also modify the boards.txt file to include an entry to use this core. This will allow the Arduino IDE to compile for the ATmega644P instead of the original Arduino's ATmega328P. Be sure to select the correct board entry inside the Arduino IDE menus. For more details on this step, check out the wiki page I linked above.
The board.txt entry:
Ro4Copter.upload.protocol=stk500
Ro4Copter.upload.maximum_size=57344
Ro4Copter.upload.speed=57600
Ro4Copter.bootloader.low_fuses=0xFF
Ro4Copter.bootloader.high_fuses=0xD8
Ro4Copter.bootloader.extended_fuses=0xFF
Ro4Copter.bootloader.path=Ro4Copter_Boot
Ro4Copter.bootloader.file=Ro4Copter_Boot_arduino.hex
Ro4Copter.bootloader.unlock_bits=0x3F
Ro4Copter.bootloader.lock_bits=0x0F
Ro4Copter.build.mcu=atmega644p
Ro4Copter.build.f_cpu=16000000L
Ro4Copter.build.core=Ro4Copter_Core
Here's a screenshot to show you where all these folders are:

The sketch you need to compile is provided in step 26. Compile it and upload it to the ATmega644P using the bootloader later.
The next few steps will help you understand what exactly the code is doing. Skip them if you don't care.
Remove these ads by
Signing Up




































































Visit Our Store »
Go Pro Today »




i cant use avrdude is there any other program to use the bootloader and please if you can explain how to use avrdude and plz plz upload the docs in any site other than google code because i cant use google code if you can please email it to me
What if I want to program my ATmega328 through Atmel AVR Studio ?
I know it is very basic question. But please answer.
Thank you very much