I am making an RGB LED project right now using the Arduino UNO board.
At this point everything is working fine so I would like to transfer this onto a small microcontroller circuit to be put inside the enclosure. Since the enclosure is small, I cannot fit the UNO board inside it, hence I want to make a small circuit on perfboard with minimal components.
I read that you can burn the arduino bootloader on a standalone AVR (hooked up to power, filter caps and 16Mhz crystal) which can then execute Arduino code.
Any idea how can I do this? Also can I do this on an ATmega8l AVR, since my code is small enough to fit in one? No point wasting a 328 if 8L can do the job.
Thanks!
-
If you have the ability to burn the bootloader to a chip then you have the ability to burn the program to it without using the bootloader.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月01日 15:57:43 +00:00Commented Dec 1, 2014 at 15:57
-
1No need for a bootloader. Just upload your program to the ATMega8 using your Uno as an ISP programmer. If you do more projects like this, it would be a good idea to buy a separate programmer like mpflaga is suggesting.Gerben– Gerben2014年12月01日 17:11:55 +00:00Commented Dec 1, 2014 at 17:11
-
Also, why the '8L instead of the '88PA (or even '48PA)?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月02日 05:08:22 +00:00Commented Dec 2, 2014 at 5:08
-
1@IgnacioVazquez-Abrams 8L because I had several of them lying unused in my parts box. Regarding burning the bootloader, I understand now that the bootloader is only required to do stuff like uploading using USB etc. Has nothing to do with the actual compiled programAnkit– Ankit2014年12月02日 19:43:27 +00:00Commented Dec 2, 2014 at 19:43
3 Answers 3
The Bootlader
If you want to burn the bootloader to the standalone AVR that you will be using, you can do so using a programmer like the USBasp
. Or, you can simply use the Arduino itself to do this.
- Open the
ArduinoISP
sketch from File > Examples. - Upload it.
- Push
reset
on the Arduino.
Wire it up
Next, wire up the AVR on a breadboard as shown here: Arduino ISP
- If you are using a variant/derivative, use a crystal that matches the crystal on your board. You might have
not_in_sync()
trouble if you don't. - Add a 10uF capacitor between
RESET
andGROUND
on the Arduino, if you are using Uno, or something similar.
Burning the Bootloader
Then select Arduino as ISP
as the programmer.
- Goto Tools > Programmer.
- Select Arduino as ISP.
Now click on Tools > Burn Bootloader.
Verifying it all works
Once that is done, open the Blink LED example and try uploading it to the AVR. You have to use the Upload using Programmer
option from File > Upload using Programmer. You can verify if it is successful, by connecting an LED to pin 19
of the AVR, and checking if it blinks.
Notes:
Remember that the pins on an AVR don't map to the corresponding pins on the Arduino, even if they are both the same chips. Search for "AVR to Arduino pin mapping" for your chip on Google. Here's the ATMega8 to Arduino pin mapping.
Don't forget to connect the ground lines of the AVR and the Arduino.
This worked for me using an ATMega8A-PU. It should work with the 8L too.
Post here if you have any problems. Glad to help
:)
-
1"First, you have to burn the bootloader to the standalone AVR that you will be using." Incorrect. You do not need the bootloader in order to use ISP, nor do you need it in order to use the Arduino libraries.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月04日 17:40:30 +00:00Commented Dec 4, 2014 at 17:40
-
1Yes, I am aware of that. OP: "I read that you can burn the arduino bootloader on a standalone AVR". I assumed the OP wanted to burn the bootloader. Will re-word the answer. Thanks for pointing it out :)pradeepcep– pradeepcep2014年12月04日 17:42:47 +00:00Commented Dec 4, 2014 at 17:42
-
1Thanks guys. I realize now my wording was quite incorrect.Ankit– Ankit2014年12月05日 14:42:57 +00:00Commented Dec 5, 2014 at 14:42
You can program the 8u2 by either using a ISP programmer such as Pocket AVR Programmer or directly over USB using the FLIPS software as documented
In reference to:
"hence I want to make a small circuit on perfboard with minimal components"
I would recommend getting Tiny AVR Programmer or alike to program ATtiny's and at use the ATtiny's directly for small specific tasks. Hence you can avoid the cost of the whole UNO if not needed. You can even emulate limited USB connection as done with the DigiSpark. They even support internal oscillator. So they often need now external parts. They can be often applied without PCB.
-
Maybe coffee needed?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月01日 17:52:35 +00:00Commented Dec 1, 2014 at 17:52
-
I would add there are several hardware library Add-on's such as code.google.com/p/arduino-tiny that give the Stock IDE native support for the Tiny's.mpflaga– mpflaga2014年12月02日 01:58:32 +00:00Commented Dec 2, 2014 at 1:58
-
1The question mentions the ATmega8L.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月02日 02:01:31 +00:00Commented Dec 2, 2014 at 2:01
Problem with Atmega8A-pu
Make sure the correct com port is selected then on the tools menu select Arduino NG or Older as the board type then choose the ATmega8 as the processor from the tools menu and upload any example Program probably i prefer blink to test (courtesy-PARC-India).
All the best