IAR Compiler Configuration

Publisher:bluepionLatest update time:2017-11-26 Source: eefocusKeywords:IAR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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


Keywords:IAR Reference address:IAR Compiler Configuration

Previous article:AVR microcontroller programming architecture
Next article:AVR's precise delay program

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号