AVR Proteus simulation lesson 1: installation and setting of AVR Studio and WinAVR

Publisher:科技创造者Latest update time:2020-01-06 Source: eefocusKeywords:avr  studio  winavr Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The avr development environment requires the installation of two software:

A must-read for beginners of WinAVR+AVR Studio

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", 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 characters) 

Enter the project name test01 in "Project name:", uncheck "Create initial file", check "Create folder", click "Next>>" 
4) Select "AVR Simulator" in "Debug platform:", select "Atmega128" in "Device:", 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) 


Successful display:

 

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 uses command line to compile files, 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) Do not have Chinese names in the project save path, that is, only in English folders (including 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, interrupt programs are declared in the ISR(...) way. Books and materials may lag behind the changes of 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:

Keywords:avr  studio  winavr Reference address:AVR Proteus simulation lesson 1: installation and setting of AVR Studio and WinAVR

Previous article:AVR microcontroller proteus simulation lesson 2: running lights
Next article:A BT problem in the transplantation of ucosii to AVR series microcontrollers

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号