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:
Previous article:AVR MCU-nRF24L01 sending and receiving program
Next article:B001-Atmega16-Interrupt (GCC-AVR)-(ques=3)
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Understanding the static electricity problems in the field of microelectronics manufacturing from the perspective of integrated circuit back-end manufacturing (chip packaging and testing)
- Today's Fujitsu Live Topic 2: Watch 3D movies without glasses, learn about German-quality naked-eye 3D technology
- Brightsign core board HS124, HS144 hardware and software development. Brightsign player
- EMC electromagnetic compatibility design and test case analysis (2nd edition)
- TMS320F28335 Serial Port SCI
- [Raspberry Pi Pico Review] FreePascal RPI Pico Engineering Structure Analysis
- 【phyBOARD-i.MX 8M Plus Development Board】Review 1: Hardware Analysis
- What are the shortcomings of smart homes? How to solve these problems?
- IGBT drive and protection circuit design and application circuit examples (2nd edition)
- The development of smartphones