Use Atmel Studio7 and USBasp to burn AVR microcontroller

Publisher:Yuexin888Latest update time:2020-03-28 Source: eefocusKeywords:Atmel Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Many tutorials provide the use of Atmel Studio and MKII to burn AVR microcontrollers, but the most popular burner used by the public is the inexpensive USBasp, which is much more affordable at around 10 yuan than the 200 yuan MKII. However, USBasp cannot be used directly for burning in Atmel Studio, so other software is usually needed, which brings more trouble.


This article uses Atmel Studio's External Tools and Avrdude software to achieve the purpose of directly burning the microcontroller in Atmel Studio. This way, programming, compiling and burning can be completed in the development environment, which is very convenient.


Step 1: You need a USBasp and its driver. Drivers are everywhere on the Internet. You can ask for them from the store when you buy the module. You can install the driver by setting the driver search path in the device manager. After the driver is installed, libusb-win32 device will appear in the device manager. Click to hide and you will see the USBasp device. As shown in the figure.

Step 2: After installing the driver, you need to install the Avrdude software. The download page is here: http://download.savannah.gnu.org/releases/avrdude/


Windows system can choose to download the zip file. After decompression, there are two files, an executable file and a configuration file. Put them in the desired directory (need to be in the same directory). Try to keep the paths of these two files unchanged, otherwise you need to reconfigure the third step.



Step 3: Open Atmel Studio software, click the Tools menu, and select External Tools. First, configure the text boxes at the bottom of the interface. The Title is optional, I wrote USBasp. In the Command input box, enter (path/)(avrdude software name).exe. If it is placed in the root directory of the D drive and the executable file is named avrdude.exe, enter D:avrdude.exe. In the Argument input box, enter:


-c usbasp -p atmega16 -B12 -U flash:w:$(ProjectDir)Debug$(TargetName).hex:i


Note: The referenced original text corresponds to the last TargetName of the above instruction, using ItemFileName, so the .c program file name and .hex file name must be the same. If your .c file name is main.c, an error will be reported.


In addition, the -p parameter of the above command is the microcontroller model. I use atmega16, so you need to change it to your model.


After setting, click the Add button and it's done. Then the Title option you set will appear under the Tools menu, as shown below.

The USBasp option appears. After writing the program, you must press F7 to compile the solution, and then click this option. After that, the Avrdude command line interface will appear, and several progress bars will appear. If only one progress bar appears and the command line interface flashes by, it may be that the compilation failed. My method is to take a screenshot at the moment of clicking to see what the error is. You can also run Avrdude directly from the CMD command line, burn the .hex file, and see the error reported.


In addition, if the fuses have not been set for a new microcontroller, you need to set the fuses first, otherwise the microcontroller will use the 1MHz internal clock by default. The fuses only need to be set once, so you can use any software to set them once and for all. If there is no fuse setting software, you can also use Avrdude as mentioned above to set them. Using the command line, first navigate to the directory where avrdude.exe is located, and then execute the command. For example, I use the atmega16 chip and set LFuse to make the microcontroller use an external crystal oscillator:


avrdude -c usbasp -p atmega16 -U lfuse:w:0xCE:m


The fuse position can be calculated using the fuse position calculator: http://www.engbedded.com/fusecalc/


Problems that may arise:

1. The original article mentioned that there may be a problem with the path in the parameter command line. The solution is to remove the two double quotes.


2. If the command line prompts that usbasp cannot be found, check the driver or try reinstalling another driver.

Keywords:Atmel Reference address:Use Atmel Studio7 and USBasp to burn AVR microcontroller

Previous article:Programming AVR Microcontrollers and Arduino Boards Using Arduino ISP
Next article:ISP programming of AVR algorithm

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号