Program / Flash Arduino Uno with Atmel Studio Elecrom January 3, 2017; Updated On: June 1st, 2019 1 Overview Programming Arduino Uno with Atmel Studio 7 is super easy. The Arduino Uno is one of the famous platforms for embedded application development using AVR microcontrollers. It is most commonly used with the Arduino’s own software tool. However, many hardcore programmers still prefer to code for AVRs in native C. This approach offers tremendous flexibility, configurability, and hackability ( 🙂 ), which otherwise hindered by the Arduino software framework. Arduino Uno board is based around ATmega328P AVR microcontroller. It has 32KB of flash memory, 2KB of SRAM, 1KB of EEPROM. It has a rich set of on-chip peripherals (6 PWM channels, 10 bit ADC, SPI, I2C, UART interfaces, Touch library support). Most important aspect of any integrated development environment is its ability to program a given microcontroller. In order to Program/Flash Arduino Uno using Atmel Studio, all we need is a humble tool called as avrdude tool. You can download this tool separately instead of downloading Arduino software. How ATmega328P Gets Programmed? If you look closely, Arduino Uno board has a one more small microcontroller (ATmega16U2). This controller emulates a virtual serial port over USB interface on one side, receives the programming commands and hex code via this virtual serial port. On the other side, it talks to the Arduino bootloader (which is factory programmed) on the ATmega328P over the UART and flashes the received hex code. Software & Tools required to Program/Flash Uno Arduino Uno board Atmel Studio (http://www.atmel.com/microsite/atmel-studio/) Avrdude ( Download and extract the archive to suitable directory – https://download.savannah.gnu.org/releases/avrdude/avrdude-6.3-mingw32.zip ) (~ 1 MB) OR Arduino 1.8.0 (https://www.arduino.cc/en/main/software) (~ 88 MB) – Avrdude is included in the Arduino installtion Steps One time setup Open Atmel Studio and click on Tools > External Tools. We will add the necessary command required to launch the avrdude from Atmel Studio and tell Atmel Studio to pass required arguments to avrdude. Click Add to add a new external tool, and provide following information: Title “` UNO avrdude “` Command “` I:\Softwares\Electronics\AVR\avrdude-6.3-mingw32\avrdude.exe “` Note: If you are using a different path, provide the same. Arguments “` -v -P COM7 -c arduino -e -p m328p -U flash:w:$(TargetName).hex “` Explanation: -v : Enable verbose output. More -v options increase verbosity level. -P : Number of the serial port (COM port) on which Arduino Uno is connected -c : Programmer hardware type. -e : Erases the Flash and EEPROM memory of the target MCU before programming. This is mandatory. -p : Short name of the device to be programmed -U : memtype:op:filename[:format] writes the content of given hex file to the flash memory NOTE: COM7 is used as an example, you need to provide the correct port. TIP: If you connect your same Arduino Uno board to the same USB port of your computer, the COM port number will always be the same 🙂 Initial Directory “` $(TargetDir) “` Select the check box Use Output Window You can refer to the screenshot below: Adding avrdude to as external tool to program Arduino Uno Click OK, and then click YES to save changes you have made. Now you will find the new external programmer tool listed as “UNO avrdude” under tools menu. Burning/Programming/Flashing the code Build your solution (press F7) Make sure Arduino Uno is connected to your computer’s USB port and COM port value specified for the tool Arguments is correct. Click Tools > UNO avrdude It should start the programming. The output window will show the log similar to the one shown below: avrdude.exe: Version 6.3, compiled on Feb 17 2016 at 09:25:53 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "I:\Softwares\Electronics\AVR\avrdude-6.3-mingw32\avrdude.conf" Using Port : COM7 Using Programmer : arduino AVR Part : ATmega328P Chip Erase delay : 9000 us PAGEL : PD7 BS2 : PC2 RESET disposition : dedicated RETRY pulse : SCK serial program mode : yes parallel program mode : yes Timeout : 200 StabDelay : 100 CmdexeDelay : 25 SyncLoops : 32 ByteDelay : 0 PollIndex : 3 PollValue : 0x53 Memory Detail : Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : Arduino Description : Arduino Hardware Version: 2 Firmware Version: 1.16 Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us avrdude.exe: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.01s avrdude.exe: Device signature = 0x1e950f (probably m328p) avrdude.exe: safemode: hfuse reads as 0 avrdude.exe: safemode: efuse reads as 0 avrdude.exe: erasing chip avrdude.exe: reading input file "My Project.hex" avrdude.exe: input file My Project.hex auto detected as Intel Hex avrdude.exe: writing flash (1906 bytes): Writing | ################################################## | 100% 0.41s avrdude.exe: 1906 bytes of flash written avrdude.exe: verifying flash memory against My Project.hex: avrdude.exe: load data flash data from input file My Project.hex: avrdude.exe: input file My Project.hex auto detected as Intel Hex avrdude.exe: input file My Project.hex contains 1906 bytes avrdude.exe: reading on-chip flash data: Reading | ################################################## | 100% 0.24s avrdude.exe: verifying ... avrdude.exe: 1906 bytes of flash verified avrdude.exe: safemode: hfuse reads as 0 avrdude.exe: safemode: efuse reads as 0 avrdude.exe: safemode: Fuses OK (E:00, H:00, L:00) avrdude.exe done. Thank you. That’s it 🙂 … now you can utilize the full power of ATmega328 MCU on Arduino Uno board ! 🙂 #Programming #Burning #Arduino-Uno #Atmel-Studio #Uno-Programming