FAQs about IAR Compilers

Publisher:睿智之光Latest update time:2022-02-12 Source: eefocusKeywords:IAR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, I started using IAR for AVR for a project. I used version 5.40, mainly because version 5.40 and above include aTtiny87. As for the installation files and harmony files, you can find them yourself, they are easy to find.


1. The compilation error is shown in the figure:

Obviously you don't have the bit definition for the enable register. To do this: Project ——> Option ——> General Options ——> System (as shown below), check


Enable bit definitions in I/O-Include files即可

2. MCU model selection


If you created it with an empty project like me, but forgot to select the MCU model used in the first step Project ——> Option ——> General Options ——> Target, otherwise the compilation will inevitably report an error, as shown in the figure below.

3. I compiled a program this afternoon, with 0 errors and 0 warnings, which was good, but it crashed as soon as I ran it and couldn't run normally at all.


In fact, I did not set the stack size properly, which caused this problem. Especially when writing large projects, this error is very likely to occur. GCC and IAR allocate stacks differently. IAR allocates stack space first, which is equivalent to defining a global array as stack space. The stack is initially at the highest address of the stack space. GCC does not need to allocate a stack first, and automatically uses the remaining RAM space as stack space. The stack is initially at the highest address of the RAM.


First compile and see how much RAM your program uses, and then see how much RAM there is in total.


Then Project ——> Option ——> Linker ——> List chooses to generate a LIST file and includes the stack option, as shown in the figure below.

In the ./Debug/list directory, get the .map (maybe .lst or other formats) file, open it with Notepad, and find the following content:


****************************************

* *

*               CALL GRAPH                     *

* *

****************************************


->Sub-tree of type: Interrupt function tree that does not make

: indirect calls

CSTACK

| Stack used (prev) : 00000000

01 int_T0_OV

| Stack used (prev) : 00000000

| + function block : 0000000C


......(N lines omitted)


01 main

| Stack used (prev) : 0000003A

| + function block : 00000000

<-Sub-tree of type: Function tree

| Stack used : 000000E2


Find the largest Stack used. Mine is 000000E2. This is the largest stack space used. I set it to 0x100 bytes to be conservative, which does not exceed the remaining RAM. Recompile and run. The emulator has no stack shortage warning and the program can run normally.


As shown below:

Keywords:IAR Reference address:FAQs about IAR Compilers

Previous article:AVR MCU-nRF24L01 sending and receiving program
Next article:B001-Atmega16-Interrupt (GCC-AVR)-(ques=3)

Latest Microcontroller Articles
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号