#define CAPD0 0x01 /* Comp. A Disable Input Buffer of Port Register .0 */
#define CAPD1 0x02 /* Comp. A Disable Input Buffer of Port Register .1 */
#define CAPD2 0x04 /* Comp. A Disable Input Buffer of Port Register .2 */
#define CAPD3 0x08 /* Comp. A Disable Input Buffer of Port Register .3 */
#define CAPD4 0x10 /* Comp. A Disable Input Buffer of Port Register .4 */
#define CAPD5 0x20 /* Comp. A Disable Input Buffer of Port Register .5 */
#define CAPD6 0x40 /* Comp. A Disable Input Buffer of Port Register .6 */
#define CAPD7 0x80 /* Comp. A Disable Input Buffer of Port Register .7 */
#define FN_0 0x0000 /*直通 */
#define FN_1 0x0001 /*2分频 */
#define FN_2 0x0002 /*3分频*/
#define FN_3 0x0003 /*4分频 */
#define FN_4 0x0004 /*5分频 */
#define FN_5 0x0005 /*6分频*/
#define FN_6 0x0006 /*7分频 */
#define FN_7 0x0007 /*8分频*/
#define FN_8 0x0008 /*9分频 */
#define FN_9 0x0009 /*10分频 */
#define FN_10 0x000A /*11分频*/
#define FN_11 0x000B /*12分频 */
#define FN_12 0x000C /*13分频*/
#define FN_13 0x000D /*14分频 */
#define FN_14 0x000E /*15分频 */
#define FN_15 0x000F /*16分频*/
#define FN_16 0x0010 /*17分频 */
#define FN_17 0x0011 /*18分频*/
#define FN_18 0x0012 /*19分频 */
#define FN_19 0x0013 /*20分频 */
#define FN_20 0x0014 /*21分频*/
#define FN_21 0x0015 /*22分频 */
#define FN_22 0x0016 /*23分频*/
#define FN_23 0x0017 /*24分频 */
#define FN_24 0x0018 /*25分频 */
#define FN_25 0x0019 /*26分频*/
#define FN_26 0x001A /*27分频 */
#define FN_27 0x001B /*28分频*/
#define FN_28 0x001C /*29分频 */
#define FN_29 0x001D /*30分频 */
#define FN_30 0x001E /*31分频*/
#define FN_31 0x001F /*32分频 */
#define FN_32 0x0020 /*33分频*/
#define FN_33 0x0021 /*34分频 */
#define FN_34 0x0022 /*35分频 */
#define FN_35 0x0023 /*36分频*/
#define FN_36 0x0024 /*37分频 */
#define FN_37 0x0025 /*38分频*/
#define FN_38 0x0026 /*39分频 */
#define FN_39 0x0027 /*40分频 */
#define FN_40 0x0028 /*41分频*/
#define FN_41 0x0029 /*42分频 */
#define FN_42 0x002A /*43分频*/
#define FN_43 0x002B /*44分频 */
#define FN_44 0x002C /*45分频 */
#define FN_45 0x002D /*46分频*/
#define FN_46 0x002E /*47分频 */
#define FN_47 0x002F /*48分频*/
#define FN_48 0x0030 /*49分频 */
#define FN_49 0x0031 /*50分频 */
#define FN_50 0x0032 /*51分频*/
#define FN_51 0x0033 /*52分频 */
#define FN_52 0x0034 /*53分频*/
#define FN_53 0x0035 /*54分频 */
#define FN_54 0x0036 /*55分频 */
#define FN_55 0x0037 /*56分频*/
#define FN_56 0x0038 /*57分频 */
#define FN_57 0x0039 /*58分频*/
#define FN_58 0x003A /*59分频 */
#define FN_59 0x003B /*60分频 */
#define FN_60 0x003C /*61分频*/
#define FN_61 0x003D /*62分频 */
#define FN_62 0x003E /*63分频*/
#define FN_63 0x003F /*64分频 */
#define FSSEL_0 0x0000 /* Flash时钟选择: ACLK */
#define FSSEL_1 0x0040 /* Flash时钟选择: MCLK */
#define FSSEL_2 0x0080 /* Flash时钟选择: SMCLK */
#define FSSEL_3 0x00C0 /* Flash时钟选择: SMCLK */
/* FLASH 控制寄存器3: 状态标志 */
#define BUSY 0x0001 /* Flash忙标志*/
#define KEYV 0x0002 /* Flash安全键值出错标志 */
#define ACCVIFG 0x0004 /* Flash非法访问中断标志*/
#define WAIT 0x0008 /* 等待指示信号位*/
#define LOCK 0x0010 /* 锁定位 */
#define EMEX 0x0020 /* 紧急退出位 */
/************************************************************
* Comparator A 比较器A寄存器定义
************************************************************/
#define CACTL1_ 0x0059 /* 比较器A控制寄存器1 */
sfrb CACTL1 = CACTL1_;
#define CACTL2_ 0x005A /* 比较器A控制寄存器2 */
sfrb CACTL2 = CACTL2_;
#define CAPD_ 0x005B /*比较器A端口禁止寄存器*/
sfrb CAPD = CAPD_;
/* 比较器A控制寄存器1 */
#define CAIFG 0x01 /*比较器A中断标志*/
#define CAIE 0x02 /* 比较器A中断使能 */
#define CAIES 0x04 /* 比较器A中断边沿触发选择 0:上升延 1:下降延 */
#define CAON 0x08 /* 比较器电源开关*/
#define CAREF0 0x10 /* 选择参考源位0 */
#define CAREF1 0x20 /* 选择参考源位1 */
#define CARSEL 0x40 /* 选择内部参考源加到比较器的正端或负端 */
#define CAEX 0x80 /* 交换比较器的输入端 */
#define CAREF_0 0x00 /* 选择参考源0 : Off 使用外部参考源*/
#define CAREF_1 0x10 /* 选择参考源1 : 0.25*Vcc为参考源 */
#define CAREF_2 0x20 /* 选择参考源2 : 0.5*Vcc为参考源 */
#define CAREF_3 0x30 /* 选择参考源3 : Vt*/
/* 比较器A控制寄存器2 */
#define CAOUT 0x01 /* 比较器输出 */
#define CAF 0x02 /* 选择比较器是否经过RC低通滤波器 */
#define P2CA0 0x04 /* 外部引脚信号连接到比较器A的CA0 */
#define P2CA1 0x08 /* 外部引脚信号连接到比较器A的CA1 */
#define CACTL24 0x10
#define CACTL25 0x20
#define CACTL26 0x40
#define CACTL27 0x80
#define CAPD0 0x01 /* Comp. A Disable Input Buffer of Port Register .0 */
#define CAPD1 0x02 /* Comp. A Disable Input Buffer of Port Register .1 */
#define CAPD2 0x04 /* Comp. A Disable Input Buffer of Port Register .2 */
#define CAPD3 0x08 /* Comp. A Disable Input Buffer of Port Register .3 */
#define CAPD4 0x10 /* Comp. A Disable Input Buffer of Port Register .4 */
#define CAPD5 0x20 /* Comp. A Disable Input Buffer of Port Register .5 */
#define CAPD6 0x40 /* Comp. A Disable Input Buffer of Port Register .6 */
#define CAPD7 0x80 /* Comp. A Disable Input Buffer of Port Register .7 */
//4
/************************************************************
* ADC12 A/D采样寄存器定义
************************************************************/
/*ADC12转换控制类寄存器*/
#define ADC12CTL0_ 0x0;' /* ADC12 Control 0 */
sfrw ADC12CTL0 = ADC12CTL0_;
#define ADC12CTL1_ 0x01A2 /* ADC12 Control 1 */
sfrw ADC12CTL1 = ADC12CTL1_;
/*ADC12中断控制类寄存器*/
#define ADC12IFG_ 0x01A4 /* ADC12 Interrupt Flag */
sfrw ADC12IFG = ADC12IFG_;
#define ADC12IE_ 0x01A6 /* ADC12 Interrupt Enable */
sfrw ADC12IE = ADC12IE_;
#define ADC12IV_ 0x01A8 /* ADC12 Interrupt Vector Word */
sfrw ADC12IV = ADC12IV_;
/*ADC12存贮器类寄存器*/
#define ADC12MEM_ 0x0140 /* ADC12 Conversion Memory */
#ifndef __IAR_SYSTEMS_ICC
#define ADC12MEM ADC12MEM_ /* ADC12 Conversion Memory (for assembler) */
#else
#define ADC12MEM ((int*) ADC12MEM_) /* ADC12 Conversion Memory (for C) */
#endif
#define ADC12MEM0_ ADC12MEM_ /* ADC12 Conversion Memory 0 */
sfrw ADC12MEM0 = ADC12MEM0_;
#define ADC12MEM1_ 0x0142 /* ADC12 Conversion Memory 1 */
sfrw ADC12MEM1 = ADC12MEM1_;
#define ADC12MEM2_ 0x0144 /* ADC12 Conversion Memory 2 */
sfrw ADC12MEM2 = ADC12MEM2_;
#define ADC12MEM3_ 0x0146 /* ADC12 Conversion Memory 3 */
sfrw ADC12MEM3 = ADC12MEM3_;
#define ADC12MEM4_ 0x0148 /* ADC12 Conversion Memory 4 */
sfrw ADC12MEM4 = ADC12MEM4_;
#define ADC12MEM5_ 0x014A /* ADC12 Conversion Memory 5 */
sfrw ADC12MEM5 = ADC12MEM5_;
#define ADC12MEM6_ 0x014C /* ADC12 Conversion Memory 6 */
sfrw ADC12MEM6 = ADC12MEM6_;
#define ADC12MEM7_ 0x014E /* ADC12 Conversion Memory 7 */
sfrw ADC12MEM7 = ADC12MEM7_;
#define ADC12MEM8_ 0x0150 /* ADC12 Conversion Memory 8 */
sfrw ADC12MEM8 = ADC12MEM8_;
#define ADC12MEM9_ 0x0152 /* ADC12 Conversion Memory 9 */
sfrw ADC12MEM9 = ADC12MEM9_;
#define ADC12MEM10_ 0x0154 /* ADC12 Conversion Memory 10 */
sfrw ADC12MEM10 = ADC12MEM10_;
#define ADC12MEM11_ 0x0156 /* ADC12 Conversion Memory 11 */
sfrw ADC12MEM11 = ADC12MEM11_;
#define ADC12MEM12_ 0x0158 /* ADC12 Conversion Memory 12 */
sfrw ADC12MEM12 = ADC12MEM12_;
#define ADC12MEM13_ 0x015A /* ADC12 Conversion Memory 13 */
sfrw ADC12MEM13 = ADC12MEM13_;
#define ADC12MEM14_ 0x015C /* ADC12 Conversion Memory 14 */
sfrw ADC12MEM14 = ADC12MEM14_;
#define ADC12MEM15_ 0x015E /* ADC12 Conversion Memory 15 */
sfrw ADC12MEM15 = ADC12MEM15_;
/*ADC12存贮控制类寄存器*/
#define ADC12MCTL_ 0x0080 /* ADC12 Memory Control */
#ifndef __IAR_SYSTEMS_ICC
#define ADC12MCTL ADC12MCTL_ /* ADC12 Memory Control (for assembler) */
#else
#define ADC12MCTL ((char*) ADC12MCTL_) /* ADC12 Memory Control (for C) */
#endif
#define ADC12MCTL0_ ADC12MCTL_ /* ADC12 Memory Control 0 */
sfrb ADC12MCTL0 = ADC12MCTL0_;
#define ADC12MCTL1_ 0x0081 /* ADC12 Memory Control 1 */
sfrb ADC12MCTL1 = ADC12MCTL1_;
#define ADC12MCTL2_ 0x0082 /* ADC12 Memory Control 2 */
sfrb ADC12MCTL2 = ADC12MCTL2_;
#define ADC12MCTL3_ 0x0083 /* ADC12 Memory Control 3 */
sfrb ADC12MCTL3 = ADC12MCTL3_;
#define ADC12MCTL4_ 0x0084 /* ADC12 Memory Control 4 */
sfrb ADC12MCTL4 = ADC12MCTL4_;
#define ADC12MCTL5_ 0x0085 /* ADC12 Memory Control 5 */
sfrb ADC12MCTL5 = ADC12MCTL5_;
#define ADC12MCTL6_ 0x0086 /* ADC12 Memory Control 6 */
sfrb ADC12MCTL6 = ADC12MCTL6_;
#define ADC12MCTL7_ 0x0087 /* ADC12 Memory Control 7 */
sfrb ADC12MCTL7 = ADC12MCTL7_;
#define ADC12MCTL8_ 0x0088 /* ADC12 Memory Control 8 */
sfrb ADC12MCTL8 = ADC12MCTL8_;
#define ADC12MCTL9_ 0x0089 /* ADC12 Memory Control 9 */
sfrb ADC12MCTL9 = ADC12MCTL9_;
#define ADC12MCTL10_ 0x008A /* ADC12 Memory Control 10 */
sfrb ADC12MCTL10 = ADC12MCTL10_;
#define ADC12MCTL11_ 0x008B /* ADC12 Memory Control 11 */
sfrb ADC12MCTL11 = ADC12MCTL11_;
#define ADC12MCTL12_ 0x008C /* ADC12 Memory Control 12 */
sfrb ADC12MCTL12 = ADC12MCTL12_;
#define ADC12MCTL13_ 0x008D /* ADC12 Memory Control 13 */
sfrb ADC12MCTL13 = ADC12MCTL13_;
#define ADC12MCTL14_ 0x008E /* ADC12 Memory Control 14 */
sfrb ADC12MCTL14 = ADC12MCTL14_;
#define ADC12MCTL15_ 0x008F /* ADC12 Memory Control 15 */
sfrb ADC12MCTL15 = ADC12MCTL15_;
/* ADC12CTL0 内16位控制寄存器位*/
#define ADC12SC 0x001 /*采样/转换控制位*/
#define ENC 0x002 /* 转换允许位*/
#define ADC12TOVIE 0x004 /*转换时间溢出中断允许位*/
#define ADC12OVIE 0x008 /*溢出中断允许位*/
#define ADC12ON 0x010 /*ADC12内核控制位*/
#define REFON 0x020 /*参考电压控制位*/
#define REF2_5V 0x040 /*内部参考电压的电压值选择位 '0'为1.5V; '1'为2.5V*/
#define MSH 0x080 /*多次采样/转换位*/
#define MSC 0x080 /*多次采样/转换位*/
/*SHT0 采样保持定时器0 控制ADC12的结果存贮器MEM0~MEM7的采样周期*/
#define SHT0_0 0*0x100 /*采样周期=TADC12CLK*4 */
#define SHT0_1 1*0x100 /*采样周期=TADC12CLK*8 */
#define SHT0_2 2*0x100 /*采样周期=TADC12CLK*16 */
#define SHT0_3 3*0x100 /*采样周期=TADC12CLK*32 */
#define SHT0_4 4*0x100 /*采样周期=TADC12CLK*64 */
#define SHT0_5 5*0x100 /*采样周期=TADC12CLK*96 */
#define SHT0_6 6*0x100 /*采样周期=TADC12CLK*128 */
#define SHT0_7 7*0x100 /*采样周期=TADC12CLK*192 */
#define SHT0_8 8*0x100 /*采样周期=TADC12CLK*256 */
#define SHT0_9 9*0x100 /*采样周期=TADC12CLK*384 */
#define SHT0_10 10*0x100 /*采样周期=TADC12CLK*512 */
#define SHT0_11 11*0x100 /*采样周期=TADC12CLK*768 */
#define SHT0_12 12*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT0_13 13*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT0_14 14*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT0_15 15*0x100 /*采样周期=TADC12CLK*1024 */
/*SHT1 采样保持定时器1 控制ADC12的结果存贮器MEM8~MEM15的采样周期*/
#define SHT1_0 0*0x100 /*采样周期=TADC12CLK*4 */
#define SHT1_1 1*0x100 /*采样周期=TADC12CLK*8 */
#define SHT1_2 2*0x100 /*采样周期=TADC12CLK*16 */
#define SHT1_3 3*0x100 /*采样周期=TADC12CLK*32 */
#define SHT1_4 4*0x100 /*采样周期=TADC12CLK*64 */
#define SHT1_5 5*0x100 /*采样周期=TADC12CLK*96 */
#define SHT1_6 6*0x100 /*采样周期=TADC12CLK*128 */
#define SHT1_7 7*0x100 /*采样周期=TADC12CLK*192 */
#define SHT1_8 8*0x100 /*采样周期=TADC12CLK*256 */
#define SHT1_9 9*0x100 /*采样周期=TADC12CLK*384 */
#define SHT1_10 10*0x100 /*采样周期=TADC12CLK*512 */
#define SHT1_11 11*0x100 /*采样周期=TADC12CLK*768 */
#define SHT1_12 12*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT1_13 13*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT1_14 14*0x100 /*采样周期=TADC12CLK*1024 */
#define SHT1_15 15*0x100 /*采样周期=TADC12CLK*1024 */
/* ADC12CTL1 内16位控制寄存器位*/
#define ADC12BUSY 0x0001 /*ADC12忙标志位*/
#define CONSEQ_0 0*2 /*单通道单次转换*/
#define CONSEQ_1 1*2 /*序列通道单次转换*/
#define CONSEQ_2 2*2 /*单通道多次转换*/
#define CONSEQ_3 3*2 /*序列通道多次转换*/
#define ADC12SSEL_0 0*8 /*ADC12内部时钟源*/
#define ADC12SSEL_1 1*8 /*ACLK*/
#define ADC12SSEL_2 2*8 /*MCLK*/
#define ADC12SSEL_3 3*8 /*SCLK*/
#define ADC12DIV_0 0*0x20 /*1分频*/
#define ADC12DIV_1 1*0x20 /*2分频*/
#define ADC12DIV_2 2*0x20 /*3分频*/
#define ADC12DIV_3 3*0x20 /*4分频*/
#define ADC12DIV_4 4*0x20 /*5分频*/
#define ADC12DIV_5 5*0x20 /*6分频*/
#define ADC12DIV_6 6*0x20 /*7分频*/
#define ADC12DIV_7 7*0x20 /*8分频*/
#define ISSH 0x0100 /*采样输入信号反向与否控制位*/
#define SHP 0x0200 /*采样信号(SAMPCON)选择控制位*/
#define SHS_0 0*0x400 /*采样信号输入源选择控制位 ADC12SC*/
#define SHS_1 1*0x400 /*采样信号输入源选择控制位 TIMER_A.OUT1*/
#define SHS_2 2*0x400 /*采样信号输入源选择控制位 TIMER_B.OUT0*/
#define SHS_3 3*0x400 /*采样信号输入源选择控制位 TIMER_B.OUT1*/
/*转换存贮器地址定义位*/
#define CSTARTADD_0 0*0x1000 /*选择MEM0首地址*/
#define CSTARTADD_1 1*0x1000 /*选择MEM1首地址*/
#define CSTARTADD_2 2*0x1000 /*选择MEM2首地址*/
#define CSTARTADD_3 3*0x1000 /*选择MEM3首地址*/
#define CSTARTADD_4 4*0x1000 /*选择MEM4首地址*/
#define CSTARTADD_5 5*0x1000 /*选择MEM5首地址*/
#define CSTARTADD_6 6*0x1000 /*选择MEM6首地址*/
#define CSTARTADD_7 7*0x1000 /*选择MEM7首地址*/
#define CSTARTADD_8 8*0x1000 /*选择MEM8首地址*/
#define CSTARTADD_9 9*0x1000 /*选择MEM9首地址*/
#define CSTARTADD_10 10*0x1000 /*选择MEM10首地址*/
#define CSTARTADD_11 11*0x1000 /*选择MEM11首地址*/
#define CSTARTADD_12 12*0x1000 /*选择MEM12首地址*/
#define CSTARTADD_13 13*0x1000 /*选择MEM13首地址*/
#define CSTARTADD_14 14*0x1000 /*选择MEM14首地址*/
#define CSTARTADD_15 15*0x1000 /*选择MEM15首地址*/
/* ADC12MCTLx */
#define INCH_0 0 /*选择模拟量通道0 A0 */
#define INCH_1 1 /*选择模拟量通道0 A1*/
#define INCH_2 2 /*选择模拟量通道0 A2*/
#define INCH_3 3 /*选择模拟量通道0 A3*/
#define INCH_4 4 /*选择模拟量通道0 A4*/
#define INCH_5 5 /*选择模拟量通道0 A5*/
#define INCH_6 6 /*选择模拟量通道0 A6*/
#define INCH_7 7 /*选择模拟量通道0 A7*/
#define INCH_8 8 /*VEREF+*/
#define INCH_9 9 /*VEREF-*/
#define INCH_10 10 /*片内温度传感器的输出*/
#define INCH_11 11 /*(AVCC-AVSS)/2*/
#define INCH_12 12 /*(AVCC-AVSS)/2*/
#define INCH_13 13 /*(AVCC-AVSS)/2*/
#define INCH_14 14 /*(AVCC-AVSS)/2*/
#define INCH_15 15 /*(AVCC-AVSS)/2*/
/*参考电压源选择位*/
#define SREF_0 0*0x10 /*VR+ = AVCC; VR- = AVSS*/
#define SREF_1 1*0x10 /*VR+ = VREF+; VR- = AVSS*/
#define SREF_2 2*0x10 /*VR+ = VEREF+; VR- = AVSS*/
#define SREF_3 3*0x10 /*VR+ = VEREF+; VR- = AVSS*/
#define SREF_4 4*0x10 /*VR+ = AVCC; VR- = VREF-*/
#define SREF_5 5*0x10 /*VR+ = VREF+; VR- = VREF-*/
#define SREF_6 6*0x10 /*VR+ = VEREF+; VR- = VREF-*/
#define SREF_7 7*0x10 /*VR+ = VEREF+; VR- = VREF-*/
#define EOS 0x80 /*序列结束选择位*/
/************************************************************
* Interrupt Vectors (offset from 0xFFE0) 16个中断矢量定义
************************************************************/
一周热门 更多>