The avr development environment requires the installation of two software:
Reprint and modify an article to explain the installation and settings of these two software
WinAVR+AVR Studio must-read for beginners
1. Obtain the necessary software.
Please obtain the latest version of AVR Studio from Atmel. For
the download address, see: http://www.cnblogs.com/proteus/archive/2011/11/09/2242583.html
. Please obtain the latest version of WinAVR from WinAVR.
Download address: http://sourceforge.net/projects/winavr/files/WinAVR/
Note: WinAVR and AVR Studio are two different software. The former is an open source project and is not owned by Atmel, while the latter is copyrighted by Atmel.
2. Installation steps
1) Install WinAVR
2) Install AVR Studio
3) Install AVR Studio Service Pack (if any)
3. Create a new test project
1) Start AVR Studio
2) Select "New Project"
3) Select "AVR GCC" in "Project type", click the button next to "Location" and select the project save location (here it is assumed to be C:\), avoid Chinese characters in the path,
(Note: make sure there is no Chinese path in the project save location, so it cannot be saved in "My Documents" or "Desktop" or other folders with Chinese paths)
Enter the project name test01 in "Project name:", uncheck "Create initial file", check "Create folder", and
click "Next>>"
4) Select "AVR Simulator" in "Debug platform:", select "Atmega128" in "Device:", and click "Finish"
5) Select File->New File, create a blank document, and copy the following code to the document (Note: there is a blank line under the last "}"):
#include "avr/io.h"
int main(void)
{
while(1);
}
6) Select File->Save, and in the "Save As" dialog box, select the folder named by the project name under the path where the project is saved (here it is assumed to be C:\test01\), and
you will see that there is already a test01.aps file, which is the project file of AVR Studio. Enter "main.c" in "File name" and save.
7) Right-click on "Source Files" in the "AVR GCC" project management pane, select "Add Existing Source File(s)..." in the right-click menu, and
select the main.c file you just created in "Add Source File". You will see that there is an additional main.c file under "Source Files" in the project management pane.
8) Menu Project->Configuration Oprions, under "General" (it is by default), confirm that "Use External MakeFile" is not checked,
fill in the frequency "8000000" in "Frequency:", select "-00" in "Optimiztion", confirm that "Create Hex File" is checked,
and then click OK (do not modify other settings)
9) Menu Build->ReBuild All, compile the project. If the operation is correct, there should be no warnings and errors.
10) Menu Debug->Start Debugging, if everything goes well, the software simulation has been started.
11) So far, the test project has been successful. You can see a default folder in the project save directory. After opening it, there are test01.elf (one of the simulation debugging file formats supported by AVR Studio) and test01.hex (the file to be used when burning).
The successful display is:
Build started 9.11.2011 at 16:14:41
avr-gcc -mmcu=atmega128 -Wl,-Map=liaojie.map main.o -o liaojie.elf
avr-objcopy -O ihex -R .eeprom -R .fuse - R .lock -R .signature liaojie.elf liaojie.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no -change-warnings -O ihex liaojie.elf liaojie.eep || exit 0
avr-objdump -h -S liaojie.elf > liaojie.lss
AVR Memory Usage
-------------
Device: atmega128
Program: 204 bytes (0.2% Full)
(.text + .data + .bootloader)
Data: 0 bytes (0.0% Full)
(.data + .bss + .noinit)
Build succeeded with 0 Warnings...
4. Advice for beginners:
If the book/material compiles files using command line, please skip the command line operations in these examples and use AVR Studio to create a new project to compile instead.
If there are explanations about Makefile, please skip them because these explanations may be too brief and difficult to understand.
1) Do not use the Makefile generated by the mfile that comes with WinAVR. Only use the AVR Studio menu Project->Configuration Oprions to configure the project (do not check "Use External MakeFile").
2) There should be no Chinese name in the project save path, that is, only in the English name folder (including the folders at all levels above it are also in English).
3) Always use Build->ReBuild All to compile the project.
4) When creating a new project, do not use Makefile as the project name (regardless of the uppercase and lowercase combination).
5) When creating a new project, do not check "Create initial file".
6) Do not modify the file name in "Output File".
7) Now, the interrupt program is declared in ISR(...). Books and materials may lag behind the changes in WinAVR. Please feel free to check the current WinAVR functions and header file descriptions through avr-libc Manual [WinAVR] under WinAVR in the start menu.
5. Further learning:
When you are more familiar with using AVR Studio to complete your project compilation process, you can consider learning Makefile.
Previous article:AVR microcontroller proteus simulation lesson 3: single digital tube
Next article:ATMEGA16 MCU fuse programming settings
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- Application and precautions of Hall elements
- Which one is better to use, the Type-C interface or the MicroUSB interface for mobile phone data cables?
- Showing goods + development board and multimeter
- Why is the GaN device [G-level is negative voltage powered]
- Program for simple control of motor interpolation motion by single chip microcomputer
- Signal Integrity and Power Integrity Analysis (3rd Edition)
- Share the FAQ about STM32/8
- Support Hongmeng OS, RT-Thread, RISC-V IDE MRS V151 was recently updated
- MCU Model Challenge 1: Guess the manufacturer and model based on the MCU's power pins.
- 【i.MX6ULL】Driver Development 9——Linux IO Model Analysis