Bootloading Atmega16 with Arduino Uno
Last two days I was experimenting with Microcontrollers and researching about how to write applications on it. I bought one Atmega16A and decided to use Arduino bootloader. So that I can write programs using Arduino IDE and syntax. This post explains about how to bootload Atmega16. I didn’t had any prior experience with Arduino, I have a uno sitting at my desk for quite a long time but never used it. Last three nights I was learning more about Arduino coding and learning about boards config and other stuffs.
Software Setup for Bootloading
I followed the steps posted by Sudar in his blog, please go through the post before reading further. Here I will write some points I had to do to do to complete the bootloading process.
Arduino IDE version: To run the core created by Sudar, we need the IDE version 1.0.x. I have the latest version 1.6.3. There are some differences in configuring boards.txt from 1.0 to 1.6. I tried to rewrite the boards.txt as per 1.6.* standard but it didn’t like it. So I downloaded the old version 1.0.6 from Arduino website. If you have 1.6.* already installed then better download the zip file and extract to a folder. That way you can use 1.6 and 1.0 in same machine.
Adding Boards and Variants: Adding boards to the sketch book folder didn’t work for me, may be I didn’t get it clearly. So I did the below steps.
-
Go to the Arduino’s hardware folder, <<IDE install location of IDE>>/hardware/arduino/ and open boards.txt.
-
Copy the contents of Atmega16 boards and pasted to the boards.txt opened in Step 1.
-
Create a new folder named mega16 under <<IDE install location>>/hardware/arduino/variants and paste the “pins_arduino.h” created for Atmega16.
-
Goto File->Examples->ArduinoISP, it will open a new window with ArduinoISP sketch. Before uploading the sketch make sure you have selected Arduino Uno in Tools->Boards->Arduino Uno. Now upload the sketch to your Uno. Now we setup our Uno as a programmer.
Hardware Setup for Bootloading
Here again I followed the pin connection detailed in Sudar’s post. Please follow exactly the way mentioned in the post. Also don’t forget to connect the capacitor between Reset and GND of Arduino.
Note: If you try to upload any sketch to Arduino Uno when the Capacitor is connected, IDE will throw errors. So before doing any thing with your Arduino remove the Capacitor.
Bootloading
Follow the below steps to burn the bootloader
-
We have to set our Arduino Uno as an ISP. To do that go to Tools->Programmer and select “Arduino as ISP”
-
Set the bootloader from Tools->Boards and select the newly added board, ie. Atmega16(internal 8mhz clock).
-
Now burn the bootloader by selecting “Burn Bootloader” under Tools menu.
If every thing works fine, you could see a success message at the bottom portion of the IDE.
Uploading Sketches to Atmega16
Next we need to upload some sketches to newly bootloaded Atmega16. For this I used the new version of Arduino IDE 1.6.3, If you want you can use IDE 1.0.*. Some how the old IDE is very slow for me, so I decided to use the new version. Skip the below step if you decided to use the old 1.0.* version.
Follow the steps to use the Atmega16 board in new version
-
Create a new folder under <<Installed location of IDE V1.6.*>>/hardware. You can name the folder anything, I named as Mega16.
-
Under Mega16 folder create another folder called “avr”.
-
Inside the avr folder copy the boards.txt and create another folder named variants and copy “pins_arduino.h” inside variants folder.
-
Open boards.txt and add the line “atmega16-8.upload.tool=arduino:avrdude”
Follow the below steps to upload sketch(Common for all versions of IDE)
-
Open up the IDE and load Blink from File->Examples->Basic.
-
Edit the code so that you are writing to a pin of Atmega16, here I write to Digital 6, it’s physical pin 20.
-
Before uploading the sketch Choose Atmega16(internal 8 Mhz) from Tools->Boards.
-
Choose “Upload using Programmer” from File menu.
Just connect a LED with a Resistor to Physical pin 20 of Atmega16 and you can see the LED blinking.
Now I can write any thing to the Atmega16 and connect to sensors or any thing I wanted to do without Arduino.
[…] my previous post I explained how to Bootload Atmega16A and program it using Arduino. Next step is to establish the […]
RS485 Communication Protocol with Micro Controllers and Raspberry pi | Sony Arouje Blog
April 23, 2015 at 11:05 pm
Hello,
After using Arduino as ISP, i can again reuse that arduino for other tasks?
Thanks
FAITH + 1 (@amitesh_singh)
December 27, 2015 at 5:19 pm
sorry for not replying, msg went to spam. Yes you can reuse the Arduino again.
Sony Arouje
March 16, 2016 at 10:19 pm
Hello,
I also able to achieve this after following your article.
I have atmega16a.
I just wonder why you used 8MHz as clock speed. i think atmega16a can work on upto 16MHz speed?
so can we use that settings?
FAITH + 1 (@amitesh_singh)
January 3, 2016 at 1:46 am
you can use 16mghz settings, I just reused what ever i downloaded from some links.
Sony Arouje
March 16, 2016 at 10:17 pm
[…] I started programming more on Atmega chips than Arduino boards. I use Arduino Uno as the ISP to bootload and program the Atmega chips. One of the difficulty I faced to use Arduino ISP is the wires running […]
Home made Arduino ISP Shield | Sony Arouje
May 16, 2016 at 11:35 pm
I AM USING USBASP FOR ATMEGA16 BUT THE PARALLEL COMMUNICATION IS OK BUT SERIAL COMMUNICATION IS NOT WORKING GOOD WHAT SHOULD I DO…..
Anonymous
August 18, 2016 at 7:39 pm
I didnt understand your question. What you mean serial communication is not working?
Sony Arouje
August 18, 2016 at 11:29 pm
Hi,
I folowed your steps and everything was fine till i started bootloading. I get “stk500_getsync(): not in sync: resp=0x00” this error and dont know what to do. Can you help me?
Anonymous
October 22, 2016 at 9:57 pm
Have a look at this post http://www.lydiard.plus.com/chapter9.htm. In recent days I use Mightycore for bootloading (https://github.com/MCUdude/MightyCore).
Sony Arouje
October 24, 2016 at 11:12 am
actually in pins_arduino.h file the pins used for ss mosi miso sck are 12 13 14 15 but according to pin connection in sudar post the pins are connected in 10 11 12 13
Mahesh
January 8, 2017 at 5:54 pm
I dont see any issue with the connection.
Sony Arouje
January 9, 2017 at 10:57 pm
Hi it seems to always give me message saying “Invalid device signature”. And verbose output seems to see the my ATMEGA16 signature as 0x000000 and it happened to two I used. Any insight on this? Thanks.
Charlie Xu
January 28, 2017 at 8:05 am
there could be different reasons for this message. It’s worth posting it in Arduino forum, any one of the member including me could help.
Sony Arouje
February 6, 2017 at 12:00 am
Arduino: 1.8.1 (Windows 10), Board: “Atmega16 (internal 8MHz clock)”
Warning: Board arduino:avr:atmega16-8 doesn’t define a ‘build.board’ preference. Auto-set to: AVR_ATMEGA16-8
:0:21: warning: ISO C99 requires whitespace after the macro name
open C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega16: The system cannot find the file specified.
Error compiling for board Atmega16 (internal 8MHz clock).
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
alroy
March 8, 2017 at 2:14 pm
you should make a video
Anonymous
March 6, 2017 at 11:49 pm
hey guys, sorry to drag up an old post.
but i followed the steps and i ended up with
” Error while burning bootloader: missing ‘bootloader.tool’ configuration parameter ”
whist trying to burn the Bootloader.
any help would be EXTERMELY APPRECIATED!!
thanks in advance, Brett.
Brett
April 8, 2017 at 3:24 pm
sorry for the late reply. This post is really old, have a look at Mighty Core (https://github.com/MCUdude/MightyCore). Recent times I used Mightycore and the isp sketch from http://www.lydiard.plus.com/chapter9.htm to bootload my Atmegas.
Sony Arouje
May 11, 2017 at 10:28 am
not working bro i have total try i have neet 1.6.6 and 1.6.4 workind only work 1.0.6 plz help me
munish
January 9, 2018 at 12:53 am