IAR編譯器配置(AVR)
一、EEPROM 區(qū)域數(shù)據(jù)存儲(chǔ):
__eeprom unsigned char a;//定義一個(gè)變量存放在EEPROM空間
__eeprom unsigned char a @ 0x8;//定義一個(gè)變量存放在EEPROM空間0X08單元
__eeprom unsigned char p[] @ 0x22//定義一個(gè)數(shù)組存放在EEPROM空間,開始地址為0X22單元
__eeprom unsigned char a @ 0x08=9;//定義一個(gè)常數(shù)存放在EEPROM空間0X08單元
__eeprom unsigned char p[] @0x22={1,2,3,4,5,6,7,8};
EEPROM操作宏取函數(shù):在comp_a90.h intrinsics.h頭文件里有詳細(xì)說(shuō)明。
自動(dòng)生成.eep文件置:在Project->Options->linker->config>的linker command line中觀察該P(yáng)roject使用了哪個(gè)XCL文件 。本文使用M8編譯,使用文件是”TOOLKIT_DIR$\src\template\cfgm8.xcl”-Ointel-extended,(CODE)=.hex
-Ointel-extended,(XDATA)=.eep
二、FLASH 區(qū)域數(shù)據(jù)存儲(chǔ):
用關(guān)鍵字__flash 控制來(lái)存放, __ flash 關(guān)鍵字寫在數(shù)據(jù)類型前后效果一樣
__flash unsigned char a @ 0x8;//定義變量存放在flash 空間0X08單元__flash
unsigned char p[] @ 0x22//定義數(shù)組存放在flash 空間,開始地址為0X22單元
__flash unsigned char a @ 0x08=9;//定義常數(shù)存放在flash 空間0X08單元
__flash unsigned char p[] @ 0x22={1,2,3,4,5,6,7,8};
unsigned int __flash * p;//定義個(gè)指向flash 空間地址的指針,16位。
unsigned int __farflash * p;//定義指向flash 空間地址的指針,24位。
__flash unsigned char * p; //定義指向SARMM空間地址的指針,指針本身存放在flash 中。
flash 操作宏函數(shù):在comp_a90.h intrinsics.h頭文件里有詳細(xì)說(shuō)明
三、IAR編譯器對(duì)位的支持更強(qiáng)大:
PORTB_ Bit2=1; //置PORTB的第2位=1
PORTC_Bit4=PORTB_Bit2;//把PORTB的第2位傳送到PORTC的第4位
四、頭文件
avr_macros.h里面包含了讀寫16位寄存器的簡(jiǎn)化書寫,和幾個(gè)位操作函數(shù)
comp_a90.h對(duì)大量的內(nèi)在函數(shù)做了簡(jiǎn)要書寫,flash 操作宏函數(shù)
ina90.h包含"inavr.h" "comp_A90.h"文件
intrinsics.h內(nèi)在函數(shù)提供最簡(jiǎn)單的操作處理器底層特征。休眠,看門狗,F(xiàn)LASH函數(shù)。
iomacro.H I/O寄存器定義文件樣本。
#include
#include
#include
#include
#include
#include
#include
#include
#include
五、extra options
1、GP-system-Data stack :0xff //堆棧大小設(shè)置
2、C/C++-Preprocessor:$PROJ_DIR$\headers\ //頭文件定位
C/C++-extra Option: --string_literals_in_flash //定義字符串在flash空間
3、Linker-Extra Option:
-Ointel-extended,(XDATA)=.eep
-Ointel-extended,(CODE)=.A90
-Ointel-extended,(CODE)=.hex
5、與ICC編譯器兼容宏定義
#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