How to Upload C Code to ِAVR Using Arduino Uno As Programmer
by alaa naser alnasef in Circuits > Arduino
1521 Views, 1 Favorites, 0 Comments
How to Upload C Code to ِAVR Using Arduino Uno As Programmer
HI everyone :D
Here I will share a simple way to program any AVR chip using Arduino Uno R3
All you need to burn the code to your microcontroller is Arduino Uno instead of buying specific programmer which cost a lot.
Supplies
You will need:
- Arduino uno r3 with removable chip (1)
- Jumper wires
- 10uF electrolyte capacitor (1)
- Hex file generated from your C code
Arduino ISP
First: open your Arduino IDE and upload Arduino ISP into your Arduino
you can find it in File -> Examples
Before pressing upload key you need to check the Board type and COM port.
NOTE: this code will turn your Arduino to a programmer!
Find the Datasheet for Your AVR and Check the Pin Out
Pin 1 is the pin that have a small dot near it
we need (VCC, GND, Reset, UCSK , MISO , MOSI) locate them in your AVR.
Connect Arduino to AVR
connect Arduino to AVR according to the Figure and your AVR datasheet
and don't forget to connect a 10uF capacitor between GND an RST of your Arduino for disabling the auto reset of Arduino
Get Your Fuse Setting and AVRDUDE APP
go to
http://www.engbedded.com/fusecalc/
and select your AVR, mine is Atmega16
I won't change anything so I don't destroy my AVR, but I will change the internal RC to 8 MHZ "You can choose external 16 MHZ crystal" it's up to you.
scroll down and copy avrdude argument
to paste it into AVRDUDE programe.
mine is
-U lfuse:w:0xe4:m -U hfuse:w:0x99:m
AVEDUDE download link:
http://download.savannah.gnu.org/releases/avrdude/
then open it and change the settings like the image and depending on your hardware and don't forget to paste the fuse settings into Additional command line args
Get Your HEX File From Your C Code
I will write a simple c code to blink a LED in PIN 20
upload hex file to avrdude in Flash section and hit program
The End
For any question comment down below