Introduction: How to Load Programs to an Arduino UNO From Atmel Studio 7

About: I'm interested in new technologies and the things that we can make in house with a few components and a bit of imagination.

In this short Instructable we are going to learn how to load a program to an Arduino UNO board using Atmel Studio instead of the Arduino IDE. This is useful when you need to develop a program using more advance features or in another language, in this case we are going to use Assembly language. If you have already try this you should know that loading a program via de arduino USB is very tricky because Atmel Studio don't have the option for doing that ,instead you should use a ICSP programmer. But we don't want to do that, so we are going to integrate the built in USB programming capabilities of our board. To do that we are going to use "avrdude" and "external tools" option in Atmel Studio.

Let's get started, the first step is download and install the Arduino IDE and Atmel Studio. You can download it from here:

This will take a lot of time to complete, but is the easiest way to have everything we will need. When you are done you can continue to the next step.

Step 1: Configuring Atmel Studio

Now plug your Arduino UNO board into your computer and wait while the drivers installs. When is done take note of the COM port it is using. You can check it in the device administrator if you missed it. In my case is "COM4" but yours may be different, so pay attention to this.

Now the real fun begins, open Atmel Studio click in the menu "tools/external tools" You will see a dialog box asking for some parameters. So let's fill the required information.

  1. In title: "Send to Arduino UNO" or the name you want.
  2. In command: "C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" this may vary according to the installation directory of the Arduino IDE. Check for avrdude.exe directory in your install.
  3. In arguments: "-C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -p atmega328p -c arduino -P COM4 -b 115200 -U flash:w:"$(ProjectDir)Debug\$(TargetName).hex":i" again this can vary according to the installation directory of the Arduino IDE. You need to replace the COM4 with the actual COM port your board is using as we see in the device administrator.
  4. Check "Use output window" box.
  5. Click OK.

We are done, you will see the new option "Send to Arduino UNO" in the tools menu.

Note: for Atmel Studio 6 users you will need to click in Tools\Select Profile and then set it to Advanced before doing this steps. Thanks to "cysix" for the information.

For Arduino Due you will need to use bossac.exe, please do this instead:

  1. In title: "Send to Arduino Due" or the name you want.
  2. In command: "C:\Program Files (x86)\Arduino\hardware\tools\bossac.exe" this may vary according to the installation directory of the Arduino IDE. Check for bossac.exe directory in your install.
  3. In arguments: "-i -d --port=COM4 -U false -e -w -v -b "$(TargetDir)$(TargetName).bin" -R" You need to replace the COM4 with the actual COM port your board is using as we see in the device administrator.
  4. Check "Use output window" box.
  5. Click OK.

Step 2: Make a Test

We are ready to go, all we need to do is make a little test. So click file/new/project and select "AVR assembler project under "Assembler" option. Click OK and select ATMEGA328P and click OK again. Now in the text editor copy and paste the following code:

 .ORG   0x0000                  // Tells the next instruction to be written
 RJMP   main                    // State that the program begins at the main label

 main:
 LDI    r16, 0xFF               // Load the immedate value 0xFF (all bits 1) into register 16
 OUT    DDRB, r16               // Set Data Direction Register B to output for all pins

 loop:
 SBI    PortB, 5                // Set the 5th bit in PortB. (i.e. turn on the LED)
 RCALL  delay_05
 CBI    PortB, 5                // Clear the 5th bit in PortB. (i.e. turn off the LED)
 RCALL  delay_05
 RJMP   loop                    // Loop again

 // Everything beneath is part of the delay loop
 delay_05:
 LDI    r16, 8

 outer_loop:
 LDI    r24, low(3037)
 LDI    r25, high(3037)

 delay_loop:
 ADIW   r24, 1
 BRNE   delay_loop
 DEC    r16
 BRNE   outer_loop
 RET

This will make the built-in led of the Arduino blink. Now click in build/build solution and after that go to tools/Send to Arduino UNO. You should see the Rx/Tx leds flashing and after that the built-in led will start blinking. And that's all, I hope you found this information useful. Now you are free to use Atmel Studio to make your Arduino projects.

This is a non-invasive way to connect your Arduino board to Atmel Studio, so you can still using it as normal with the Arduino IDE. If you have a different board avrdude must be configured properly according the board you want to use.

If you like it, and want to support me give me a like in my store fanpage: DAFR ELECTRONICS and also vote for this instructable in the contest.
Thank you, I hope you find it helpful. If you have a question feel free to ask ;)

Written by:

Daniel Fernandez R.

Digital Life 101 Challenge

Participated in the
Digital Life 101 Challenge

Hack Your Day Contest

Participated in the
Hack Your Day Contest

Full Spectrum Laser Contest 2016

Participated in the
Full Spectrum Laser Contest 2016