IAR Compiler Configuration (AVR)
1. EEPROM area data storage:
__eeprom unsigned char a; //Define a variable and store it in the EEPROM space
__eeprom unsigned char a @ 0x8; //Define a variable and store it in the EEPROM space 0X08 unit
__eeprom unsigned char p[] @ 0x22 //Define an array and store it in the EEPROM space, with the starting address being the 0X22 unit
__eeprom unsigned char a @ 0x08=9; //Define a constant and store it in the EEPROM space 0X08 unit
__eeprom unsigned char p[] @0x22={1,2,3,4,5,6,7,8};
EEPROM operation macro function: detailed description is in the comp_a90.h intrinsics.h header file.
Automatically generate .eep file settings: Observe which XCL file the project uses in the linker command line of Project->Options->linker->config>. This article uses M8 compilation, and the file used is "TOOLKIT_DIR$\src\template\cfgm8.xcl" -Ointel-extended, (CODE) = .hex
-Ointel-extended, (XDATA) = .eep
2. FLASH area data storage:
Use the keyword __flash to control storage. The effect of writing the __flash keyword before and after the data type is the same
__flash unsigned char a @ 0x8; //Define variables and store them in flash space 0X08 unit __flash
unsigned char p[] @ 0x22 //Define arrays and store them in flash space, with the starting address being 0X22 unit
__flash unsigned char a @ 0x08=9; //Define constants and store them in flash space 0X08 unit
__flash unsigned char p[] @ 0x22={1, 2, 3, 4, 5, 6, 7, 8};
unsigned int __flash * p; //Define a pointer to the flash space address, 16 bits.
unsigned int __farflash * p; //Define a pointer to the flash space address, 24 bits.
__flash unsigned char * p; //Define a pointer to the SARMM space address, the pointer itself is stored in the flash.
Flash operation macro function: detailed description in the comp_a90.h intrinsics.h header file
3. IAR compiler has stronger support for bits:
PORTB_ Bit2 = 1; //Set the second bit of PORTB = 1
PORTC_Bit4 = PORTB_Bit2; //Transfer the second bit of PORTB to the fourth bit of PORTC
4. The header file
avr_macros.h contains simplified writing of reading and writing 16-bit registers, and several bit operation functions.
comp_a90.h briefly writes a large number of intrinsic functions. The flash operation macro function
ina90.h contains "inavr.h" and "comp_A90.h". The file
intrinsics.h provides the simplest operation of the processor's underlying features. Sleep, watchdog, FLASH functions.
iomacro.HI/O register definition file sample.
#include
#include
#include #include
#include
#include
#include
#include
#include
5. Extra options
1. GP-system-Data stack: 0xff //Stack size setting
2. C/C++-Preprocessor: $PROJ_DIR$\headers\ //Header file location
C/C++-extra Option: --string_literals_in_flash //Define string in flash space
3. Linker-Extra Option:
-Ointel-extended,(XDATA)=.eep
-Ointel-extended,(CODE)=.A90
-Ointel-extended,(CODE)=.hex
5. Compatible with ICC compiler macro definition
#ifndef __ICCAVR__
#define __ICCAVR__
#endif
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
#define NOP() __no_operation() //asm("nop")
#define CLI() __disable_interrupt() //asm("cli" )
#define SEI() __enable_interrupt() //asm("sei")
#pragma language=extended
#ifndef ENABLE_BIT_DEFINITIONS
#define ENABLE_BIT_DEFINITIONS
#endif
Previous article:AVR microcontroller programming architecture
Next article:AVR's precise delay program
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- [Infineon XENSIV PAS CO2 sensor] Unboxing
- CircuitPython's Python programming software MU
- TouchGFX multi-screen switching has no transition effect, can you please help?
- Microchip Live Today | TA100-VAO performs secure boot and message authentication on CAN FD for ADAS and IVI systems
- 【Paper Sharing】Low-profile Balun Design for Balanced Feeding of Ultra-wideband Antennas
- Regarding MOS tube driver IC, can it only work in PWM mode?
- PCB printed circuit board design technology and practice
- [Top Micro Smart Display Screen Review] 1. Screen interface introduction and power consumption test and serial communication test
- Temperature Problems Solved for You (III) High-Performance Processor Mold Temperature Monitoring
- AD13 This box can't be found