Monday, September 28, 2020

Using USBTinyISP programmer with Atmel Studio 7 | AVR programming

In the last article I talked about Programming any AVR microcontrollers using WinAVR and USBTinyISP but recently I found that USBTinyISP can be easily used together with Microchip Studio.

For microcontrollers that are using UPDI interface for programming, I have another tutorial here.

Using USBTinyISP programmer with Atmel Studio

Using an external programmer in Microchip Studio 7

To add USBTiny to Microchip Studio go to Tools -> External Tools

Using an external programmer in Atmel Studio 7


Add USBTiny to Atmel Studio

Here pick a name for the programming tool, for example USBTinyISP_Debug or USBTinyISP_Release.

In the command field write avrdude.exe. For this to work you need to download avrdude and unzip it in a folder at an arbitrary location. Then add avrdude to the Windows system path otherwise instead of avrdude.exe you need to provide the full path to the executable. Here is how to add an application to the Windows path.

To check if avrdude is installed and added to Path, open a command prompt window, type avrdude and press enter. You should now see something like this:

avrdude cmd

In the arguments field specify what arguments will be sent to avrdude.exe

-c usbtiny -p m328p -U flash:w:$(ProjectDir)Debug\$(TargetName).hex:i

-c : specify programmer type. For USBTinyISP use usbtiny. To see a list of all supported programmers use avrdude -c abcd

-p : the avr device. For example ATmega328P is m328p. To see a full list of microcontrollers use avrdude -c usbtiny -p abcd

-U : indicates that we want to :w: write to flash memory the .hex file. :i is Intel hex file format. $(ProjectDir) and $(TargetName) is specific to Microchip Studio 7. In Atmel Studio 6 this can differ. Replace Debug with Release when working in Release mode.

Lastly, check the Use Output Window.

Now in the Tools menu you should see the tool above the External Tools.... You can add as many as you want. For example one for Debug and one for Release.

Atmel Studio external tools

When having more than one project in one solution (more than one microcontroller type), select the main.c file before uploading the code to ensure the proper hex file will be used.

That's it! Now after building the code (F7), you can upload it to the microcontroller using Tools -> and the newly created programming tool.

2 comments: