早在学习51单片机时就在想这几个头文件到底有什么区别,在不同的地方有不同的用法。现在再回过头来看心中不禁了然。
reg52.h和stc15f2k60s2.h对于使用蓝桥杯的板子,都可以正常使用,但是又有一些区别,简单来说,我们单片机比赛中用的芯片的寄存器在stc15f2k60s2.h中的定义更完善。我们可以直接书写文档,而不用自己再去定义某些reg52.h没有定义的寄存器。另外,比赛的板子如果要用硬件仿真功能,也需要STC12F2K60S2工程。总的说来这几个头文件最大的区别就是完善程度了,有些管脚定义了,有些则没有,在使用的时候注意区分便是,下面贴出他们头文件的具体内容:
/*--------------------------------------------------------------------------
REG52.H
Header file for generic 80C52 and 80C32 microcontroller.
Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/
#ifndef __REG52_H__
#define __REG52_H__
/* 特殊字节(8位)寄存器 */
sfr P0 = 0x80; // P0口特殊寄存器寻址位
sfr P1 = 0x90; // P1口特殊寄存器寻址位
sfr P2 = 0xA0; // P2口特殊寄存器寻址位
sfr P3 = 0xB0; // P3口特殊寄存器寻址位
sfr PSW = 0xD0; //程序状态字寄存器
sfr ACC = 0xE0; //累加器
sfr B = 0xF0; //B 特殊寄存器
sfr SP = 0x81; //堆栈指针寄存器
sfr DPL = 0x82; //数字指针(低位)
sfr DPH = 0x83; //数字指针(高位)
sfr PCON = 0x87; //电源控制寄存器
sfr TCON = 0x88; //定时器/计数器 0 和 1 控制
sfr TMOD = 0x89; //定时器/计数器 0 和 1 模式
sfr TL0 = 0x8A; //定时器/计数器 0 低8位寄存器
sfr TL1 = 0x8B; //定时器/计数器 1低8位寄存器
sfr TH0 = 0x8C; //定时器/计数器 0高8位寄存器
sfr TH1 = 0x8D; //定时器/计数器 1高8位寄存器
sfr IE = 0xA8; //中断允许寄存器
sfr IP = 0xB8; //中断优先寄存器(低)
sfr SCON = 0x98; //串口控制寄存器
sfr SBUF = 0x99; //串口数据缓冲器
/* 8052扩展寄存器 */
sfr T2CON = 0xC8; //定时器/计数器2 控制
sfr RCAP2L = 0xCA; //定时器/计数器2 重载/捕捉低位
sfr RCAP2H = 0xCB; //定时器/计数器2 重载/捕捉高位
sfr TL2 = 0xCC; //定时器/计数器2 低位
sfr TH2 = 0xCD; //定时器/计数器2 高位
/* 位寄存器 */
/* PSW (程序状态字寄存器) */
sbit CY = PSW^7; //进位、借位标志。进位、借位CY=1;否则CY=0
sbit AC = PSW^6; //辅助进位、借位标志。当D3向D4有借位或进位时,AC=1;否则AC=0
sbit F0 = PSW^5; //用户标志位
sbit RS1 = PSW^4; //寄存器组选择控制位1
sbit RS0 = PSW^3; //寄存器组选择控制位0
sbit OV = PSW^2; //溢出标志。有溢出OV=1,否则OV=0
sbit F1 = PSW^1; //保留位,无定义
sbit P = PSW^0; //8052 only 奇偶校验标志位,由硬件置位或清0;
//存在ACC中的运算结果有奇数个1时P=1,否则P=0
/* TCON (定时器/计数器 0 和 1 控制) */
sbit TF1 = TCON^7; //定时器1溢出标志位。当字时器1计满溢出时,
//由硬件使TF1置“1”,并且申请中断。
//进入中断服务程序后,由硬件自动清“0”,在查询方式下用软件清 “0”
sbit TR1 = TCON^6; //定时器1运行控制位。由软件清“0”关闭定时器1。
//当GATE=1,且INT1为高电平时,TR1置“1”启动定时器1;
//当GATE=0,TR1置“1” 启动定时器1
sbit TF0 = TCON^5; //定时器0溢出标志。其功能及操作情况同TF1。
sbit TR0 = TCON^4; //定时器0运行控制位。其功能及操作情况同TR1。
sbit IE1 = TCON^3; //外部中断1请求标志。
sbit IT1 = TCON^2; //外部中断1触发方式选择位。
sbit IE0 = TCON^1; //外部中断0请求标志。
sbit IT0 = TCON^0; //外部中断0触发方式选择位。
/* IE (中断允许寄存器) */
sbit EA = IE^7; //允许/禁止总中断
sbit ET2 = IE^5; //8052 only 允许/禁止定时器2(T2)中断
sbit ES = IE^4; //允许/禁止串口中断
sbit ET1 = IE^3; //允许/禁止T1溢出中断
sbit EX1 = IE^2; //允许/禁止外部中断1(INT1)
sbit ET0 = IE^1; //允许/禁止T0溢出中断
sbit EX0 = IE^0; //允许/禁止外部中断0(INT0)
/* IP (中断优先寄存器低) */
sbit PT2 = IP^5; //定时/计数器T2优先级设定位。
sbit PS = IP^4; //串行口优先级设定位;
sbit PT1 = IP^3; //定时/计数器T1优先级设定位;
sbit PX1 = IP^2; //外部中断0优先级设定位;
sbit PT0 = IP^1; //定时/计数器T0优先级设定位;
sbit PX0 = IP^0; //外部中断0优先级设定位;
/* P3 (第二功能) */
sbit RD = P3^7; //外部数据存储器读脉冲
sbit WR = P3^6; //外部数据存储器写脉冲
sbit T1 = P3^5; //定时器/计数器1外部输入
sbit T0 = P3^4; //定时器/计数器0外部输入
sbit INT1 = P3^3; //外部中断0。
sbit INT0 = P3^2; //外部中断1。
sbit TXD = P3^1; //串行数据输出口
sbit RXD = P3^0; //串行数据输入口
/* SCON(控制寄存器,它是一个可寻址的专用寄存器,用于串行数据的通信控制) */
sbit SM0 = SCON^7; //串行口工作方式控制位0。
sbit SM1 = SCON^6; //串行口工作方式控制位1。
sbit SM2 = SCON^5; //多机通信控制位。
sbit REN = SCON^4; //允许接收位。用于控制数据接收的允许和禁止,
// ren=1时,允许接收,ren=0时,禁止接收。
sbit TB8 = SCON^3; //发送接收数据位8。
sbit RB8 = SCON^2; //接收数据位8。
sbit TI = SCON^1; //发送中断标志位。
sbit RI = SCON^0; //接收中断标志位。
/* P1(第二功能) */
sbit T2EX = P1^1; // 8052 only 定时/计数器2捕捉/重装入触发
sbit T2 = P1^0; // 8052 only 定时/计数器2外部输入
/* T2CON (定时器/计数器2 控制) */
sbit TF2 = T2CON^7; //定时器2 溢出标记
sbit EXF2 = T2CON^6; //定时器2 外部标记
sbit RCLK = T2CON^5; //0=串口时钟应用定时器1 溢出, 1=定时器 2
sbit TCLK = T2CON^4; //0=串口时钟应用定时器1 溢出, 1=定时器 2
sbit EXEN2 = T2CON^3; //定时器 2 外部允许
sbit TR2 = T2CON^2; //0=停止定时器, 1=开始定时器
sbit C_T2 = T2CON^1; //0=定时器, 1=计数器
sbit CP_RL2 = T2CON^0; //0=重载, 1=捕捉选择。
#endif
/*--------------------------------------------------------------------------
REG51.H
Header file for generic 80C51 and 80C31 microcontroller.
Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/
#ifndef __REG51_H__
#define __REG51_H__
/* BYTE Register */
sfr P0 = 0x80;
sfr P1 = 0x90;
sfr P2 = 0xA0;
sfr P3 = 0xB0;
sfr PSW = 0xD0;
sfr ACC = 0xE0;
sfr B = 0xF0;
sfr SP = 0x81;
sfr DPL = 0x82;
sfr DPH = 0x83;
sfr PCON = 0x87;
sfr TCON = 0x88;
sfr TMOD = 0x89;
sfr TL0 = 0x8A;
sfr TL1 = 0x8B;
sfr TH0 = 0x8C;
sfr TH1 = 0x8D;
sfr IE = 0xA8;
sfr IP = 0xB8;
sfr SCON = 0x98;
sfr SBUF = 0x99;
/* BIT Register */
/* PSW */
sbit CY = 0xD7;
sbit AC = 0xD6;
sbit F0 = 0xD5;
sbit RS1 = 0xD4;
sbit RS0 = 0xD3;
sbit OV = 0xD2;
sbit P = 0xD0;
/* TCON */
sbit TF1 = 0x8F;
sbit TR1 = 0x8E;
sbit TF0 = 0x8D;
sbit TR0 = 0x8C;
sbit IE1 = 0x8B;
sbit IT1 = 0x8A;
sbit IE0 = 0x89;
sbit IT0 = 0x88;
/* IE */
sbit EA = 0xAF;
sbit ES = 0xAC;
sbit ET1 = 0xAB;
sbit EX1 = 0xAA;
sbit ET0 = 0xA9;
sbit EX0 = 0xA8;
/* IP */
sbit PS = 0xBC;
sbit PT1 = 0xBB;
sbit PX1 = 0xBA;
sbit PT0 = 0xB9;
sbit PX0 = 0xB8;
/* P3 */
sbit RD = 0xB7;
sbit WR = 0xB6;
sbit T1 = 0xB5;
sbit T0 = 0xB4;
sbit INT1 = 0xB3;
sbit INT0 = 0xB2;
sbit TXD = 0xB1;
sbit RXD = 0xB0;
/* SCON */
sbit SM0 = 0x9F;
sbit SM1 = 0x9E;
sbit SM2 = 0x9D;
sbit REN = 0x9C;
sbit TB8 = 0x9B;
sbit RB8 = 0x9A;
sbit TI = 0x99;
sbit RI = 0x98;
#endif
/*--------------------------------------------------------------------------
AT89X52.H
Header file for the low voltage Flash Atmel AT89C52 and AT89LV52.
Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
All rights reserved.
--------------------------------------------------------------------------*/
#ifndef __AT89X52_H__
#define __AT89X52_H__
/*------------------------------------------------
Byte Registers
------------------------------------------------*/
sfr P0 = 0x80;
sfr SP = 0x81;
sfr DPL = 0x82;
sfr DPH = 0x83;
sfr PCON = 0x87;
sfr TCON = 0x88;
sfr TMOD = 0x89;
sfr TL0 = 0x8A;
sfr TL1 = 0x8B;
sfr TH0 = 0x8C;
sfr TH1 = 0x8D;
sfr P1 = 0x90;
sfr SCON = 0x98;
sfr SBUF = 0x99;
sfr P2 = 0xA0;
sfr IE = 0xA8;
sfr P3 = 0xB0;
sfr IP = 0xB8;
sfr T2CON = 0xC8;
sfr T2MOD = 0xC9;
sfr RCAP2L = 0xCA;
sfr RCAP2H = 0xCB;
sfr TL2 = 0xCC;
sfr TH2 = 0xCD;
sfr PSW = 0xD0;
sfr ACC = 0xE0;
sfr B = 0xF0;
/*------------------------------------------------
P0 Bit Registers
------------------------------------------------*/
sbit P0_0 = 0x80;
sbit P0_1 = 0x81;
sbit P0_2 = 0x82;
sbit P0_3 = 0x83;
sbit P0_4 = 0x84;
sbit P0_5 = 0x85;
sbit P0_6 = 0x86;
sbit P0_7 = 0x87;
/*------------------------------------------------
PCON Bit Values
------------------------------------------------*/
#define IDL_ 0x01
#define STOP_ 0x02
#define PD_ 0x02 /* Alternate definition */
#define GF0_ 0x04
#define GF1_ 0x08
#define SMOD_ 0x80
/*------------------------------------------------
TCON Bit Registers
------------------------------------------------*/
sbit IT0 = 0x88;
sbit IE0 = 0x89;
sbit IT1 = 0x8A;
sbit IE1 = 0x8B;
sbit TR0 = 0x8C;
sbit TF0 = 0x8D;
sbit TR1 = 0x8E;
sbit TF1 = 0x8F;
/*------------------------------------------------
TMOD Bit Values
------------------------------------------------*/
#define T0_M0_ 0x01
#define T0_M1_ 0x02
#define T0_CT_ 0x04
#define T0_GATE_ 0x08
#define T1_M0_ 0x10
#define T1_M1_ 0x20
#define T1_CT_ 0x40
#define T1_GATE_ 0x80
#define T1_MASK_ 0xF0
#define T0_MASK_ 0x0F
/*------------------------------------------------
P1 Bit Registers
------------------------------------------------*/
sbit P1_0 = 0x90;
sbit P1_1 = 0x91;
sbit P1_2 = 0x92;
sbit P1_3 = 0x93;
sbit P1_4 = 0x94;
sbit P1_5 = 0x95;
sbit P1_6 = 0x96;
sbit P1_7 = 0x97;
sbit T2 = 0x90; /* External input to Timer/Counter 2, clock out */
sbit T2EX = 0x91; /* Timer/Counter 2 capture/reload trigger & dir ctl */
/*------------------------------------------------
SCON Bit Registers
------------------------------------------------*/
sbit RI = 0x98;
sbit TI = 0x99;
sbit RB8 = 0x9A;
sbit TB8 = 0x9B;
sbit REN = 0x9C;
sbit SM2 = 0x9D;
sbit SM1 = 0x9E;
sbit SM0 = 0x9F;
/*------------------------------------------------
P2 Bit Registers
------------------------------------------------*/
sbit P2_0 = 0xA0;
sbit P2_1 = 0xA1;
sbit P2_2 = 0xA2;
sbit P2_3 = 0xA3;
sbit P2_4 = 0xA4;
sbit P2_5 = 0xA5;
sbit P2_6 = 0xA6;
sbit P2_7 = 0xA7;
/*------------------------------------------------
IE Bit Registers
------------------------------------------------*/
sbit EX0 = 0xA8; /* 1=Enable External interrupt 0 */
sbit ET0 = 0xA9; /* 1=Enable Timer 0 interrupt */
sbit EX1 = 0xAA; /* 1=Enable External interrupt 1 */
sbit ET1 = 0xAB; /* 1=Enable Timer 1 interrupt */
sbit ES = 0xAC; /* 1=Enable Serial port interrupt */
sbit ET2 = 0xAD; /* 1=Enable Timer 2 interrupt */
sbit EA = 0xAF; /* 0=Disable all interrupts */
/*------------------------------------------------
P3 Bit Registers (Mnemonics & Ports)
------------------------------------------------*/
sbit P3_0 = 0xB0;
sbit P3_1 = 0xB1;
sbit P3_2 = 0xB2;
sbit P3_3 = 0xB3;
sbit P3_4 = 0xB4;
sbit P3_5 = 0xB5;
sbit P3_6 = 0xB6;
sbit P3_7 = 0xB7;
sbit RXD = 0xB0; /* Serial data input */
sbit TXD = 0xB1; /* Serial data output */
sbit INT0 = 0xB2; /* External interrupt 0 */
sbit INT1 = 0xB3; /* External interrupt 1 */
sbit T0 = 0xB4; /* Timer 0 external input */
sbit T1 = 0xB5; /* Timer 1 external input */
sbit WR = 0xB6; /* External data memory write strobe */
sbit RD = 0xB7; /* External data memory read strobe */
/*------------------------------------------------
IP Bit Registers
------------------------------------------------*/
sbit PX0 = 0xB8;
sbit PT0 = 0xB9;
sbit PX1 = 0xBA;
sbit PT1 = 0xBB;
sbit PS = 0xBC;
sbit PT2 = 0xBD;
/*------------------------------------------------
T2CON Bit Registers
------------------------------------------------*/
sbit CP_RL2= 0xC8; /* 0=Reload, 1=Capture select */
sbit C_T2 = 0xC9; /* 0=Timer, 1=Counter */
sbit TR2 = 0xCA; /* 0=Stop timer, 1=Start timer */
sbit EXEN2= 0xCB; /* Timer 2 external enable */
sbit TCLK = 0xCC; /* 0=Serial clock uses Timer 1 overflow, 1=Timer 2 */
sbit RCLK = 0xCD; /* 0=Serial clock uses Timer 1 overflow, 1=Timer 2 */
sbit EXF2 = 0xCE; /* Timer 2 external flag */
sbit TF2 = 0xCF; /* Timer 2 overflow flag */
/*------------------------------------------------
T2MOD Bit Values
------------------------------------------------*/
#define DCEN_ 0x01 /* 1=Timer 2 can be configured as up/down counter */
#define T2OE_ 0x02 /* Timer 2 output enable */
/*------------------------------------------------
PSW Bit Registers
------------------------------------------------*/
sbit P = 0xD0;
sbit F1 = 0xD1;
sbit OV = 0xD2;
sbit RS0 = 0xD3;
sbit RS1 = 0xD4;
sbit F0 = 0xD5;
sbit AC = 0xD6;
sbit CY = 0xD7;
/*------------------------------------------------
Interrupt Vectors:
Interrupt Address = (Number * 8) + 3
------------------------------------------------*/
#define IE0_VECTOR 0 /* 0x03 External Interrupt 0 */
#define TF0_VECTOR 1 /* 0x0B Timer 0 */
#define IE1_VECTOR 2 /* 0x13 External Interrupt 1 */
#define TF1_VECTOR 3 /* 0x1B Timer 1 */
#define SIO_VECTOR 4 /* 0x23 Serial port */
#define TF2_VECTOR 5 /* 0x2B Timer 2 */
#define EX2_VECTOR 5 /* 0x2B External Interrupt 2 */
#endif
#ifndef __STC15F2K60S2_H_
#define __STC15F2K60S2_H_
/
//注意: STC15W4K32S4系列的芯片,上电后所有与PWM相关的IO口均为
// 高阻态,需将这些口设置为准双向口或强推挽模式方可正常使用
//相关IO: P0.6/P0.7/P1.6/P1.7/P2.1/P2.2
// P2.3/P2.7/P3.7/P4.2/P4.4/P4.5
/
/
//包含本头文件后,不用另外再包含"REG51.H"
//内核特殊功能寄存器 // 复位值 描述
sfr ACC = 0xE0; //0000,0000 累加器Accumulator
sfr B = 0xF0; //0000,0000 B寄存器
sfr PSW = 0xD0; //0000,0000 程序状态字
sbit CY = PSW^7;
sbit AC = PSW^6;
sbit F0 = PSW^5;
sbit RS1 = PSW^4;
sbit RS0 = PSW^3;
sbit OV = PSW^2;
sbit P = PSW^0;
sfr SP = 0x81; //0000,0111 堆栈指针
sfr DPL = 0x82; //0000,0000 数据指针低字节
sfr DPH = 0x83; //0000,0000 数据指针高字节
//I/O 口特殊功能寄存器
sfr P0 = 0x80; //1111,1111 端口0
sbit P00 = P0^0;
sbit P01 = P0^1;
sbit P02 = P0^2;
sbit P03 = P0^3;
sbit P04 = P0^4;
sbit P05 = P0^5;
sbit P06 = P0^6;
sbit P07 = P0^7;
sfr P1 = 0x90; //1111,1111 端口1
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
sbit P13 = P1^3;
sbit P14 = P1^4;
sbit P15 = P1^5;
sbit P16 = P1^6;
sbit P17 = P1^7;
sfr P2 = 0xA0; //1111,1111 端口2
sbit P20 = P2^0;
sbit P21 = P2^1;
sbit P22 = P2^2;
sbit P23 = P2^3;
sbit P24 = P2^4;
sbit P25 = P2^5;
sbit P26 = P2^6;
sbit P27 = P2^7;
sfr P3 = 0xB0; //1111,1111 端口3
sbit P30 = P3^0;
sbit P31 = P3^1;
sbit P32 = P3^2;
sbit P33 = P3^3;
sbit P34 = P3^4;
sbit P35 = P3^5;
sbit P36 = P3^6;
sbit P37 = P3^7;
sfr P4 = 0xC0; //1111,1111 端口4
sbit P40 = P4^0;
sbit P41 = P4^1;
sbit P42 = P4^2;
sbit P43 = P4^3;
sbit P44 = P4^4;
sbit P45 = P4^5;
sbit P46 = P4^6;
sbit P47 = P4^7;
sfr P5 = 0xC8; //xxxx,1111 端口5
sbit P50 = P5^0;
sbit P51 = P5^1;
sbit P52 = P5^2;
sbit P53 = P5^3;
sbit P54 = P5^4;
sbit P55 = P5^5;
sbit P56 = P5^6;
sbit P57 = P5^7;
sfr P6 = 0xE8; //0000,0000 端口6
sbit P60 = P6^0;
sbit P61 = P6^1;
sbit P62 = P6^2;
sbit P63 = P6^3;
sbit P64 = P6^4;
sbit P65 = P6^5;
sbit P66 = P6^6;
sbit P67 = P6^7;
sfr P7 = 0xF8; //0000,0000 端口7
sbit P70 = P7^0;
sbit P71 = P7^1;
sbit P72 = P7^2;
sbit P73 = P7^3;
sbit P74 = P7^4;
sbit P75 = P7^5;
sbit P76 = P7^6;
sbit P77 = P7^7;
sfr P0M0 = 0x94; //0000,0000 端口0模式寄存器0
sfr P0M1 = 0x93; //0000,0000 端口0模式寄存器1
sfr P1M0 = 0x92; //0000,0000 端口1模式寄存器0
sfr P1M1 = 0x91; //0000,0000 端口1模式寄存器1
sfr P2M0 = 0x96; //0000,0000 端口2模式寄存器0
sfr P2M1 = 0x95; //0000,0000 端口2模式寄存器1
sfr P3M0 = 0xB2; //0000,0000 端口3模式寄存器0
sfr P3M1 = 0xB1; //0000,0000 端口3模式寄存器1
sfr P4M0 = 0xB4; //0000,0000 端口4模式寄存器0
sfr P4M1 = 0xB3; //0000,0000 端口4模式寄存器1
sfr P5M0 = 0xCA; //0000,0000 端口5模式寄存器0
sfr P5M1 = 0xC9; //0000,0000 端口5模式寄存器1
sfr P6M0 = 0xCC; //0000,0000 端口6模式寄存器0
sfr P6M1 = 0xCB; //0000,0000 端口6模式寄存器1
sfr P7M0 = 0xE2; //0000,0000 端口7模式寄存器0
sfr P7M1 = 0xE1; //0000,0000 端口7模式寄存器1
//系统管理特殊功能寄存器
sfr PCON = 0x87; //0001,0000 电源控制寄存器
sfr AUXR = 0x8E; //0000,0000 辅助寄存器
sfr AUXR1 = 0xA2; //0000,0000 辅助寄存器1
sfr P_SW1 = 0xA2; //0000,0000 外设端口切换寄存器1
sfr CLK_DIV = 0x97; //0000,0000 时钟分频控制寄存器
sfr BUS_SPEED = 0xA1; //xx10,x011 总线速度控制寄存器
sfr P1ASF = 0x9D; //0000,0000 端口1模拟功能配置寄存器
sfr P_SW2 = 0xBA; //0xxx,x000 外设端口切换寄存器
//中断特殊功能寄存器
sfr IE = 0xA8; //0000,0000 中断控制寄存器
sbit EA = IE^7;
sbit ELVD = IE^6;
sbit EADC = IE^5;
sbit ES = IE^4;
sbit ET1 = IE^3;
sbit EX1 = IE^2;
sbit ET0 = IE^1;
sbit EX0 = IE^0;
sfr IP = 0xB8; //0000,0000 中断优先级寄存器
sbit PPCA = IP^7;
sbit PLVD = IP^6;
sbit PADC = IP^5;
sbit PS = IP^4;
sbit PT1 = IP^3;
sbit PX1 = IP^2;
sbit PT0 = IP^1;
sbit PX0 = IP^0;
sfr IE2 = 0xAF; //0000,0000 中断控制寄存器2
sfr IP2 = 0xB5; //xxxx,xx00 中断优先级寄存器2
sfr INT_CLKO = 0x8F; //0000,0000 外部中断与时钟输出控制寄存器
//定时器特殊功能寄存器
sfr TCON = 0x88; //0000,0000 T0/T1控制寄存器
sbit TF1 = TCON^7;
sbit TR1 = TCON^6;
sbit TF0 = TCON^5;
sbit TR0 = TCON^4;
sbit IE1 = TCON^3;
sbit IT1 = TCON^2;
sbit IE0 = TCON^1;
sbit IT0 = TCON^0;
sfr TMOD = 0x89; //0000,0000 T0/T1模式寄存器
sfr TL0 = 0x8A; //0000,0000 T0低字节
sfr TL1 = 0x8B; //0000,0000 T1低字节
sfr TH0 = 0x8C; //0000,0000 T0高字节
sfr TH1 = 0x8D; //0000,0000 T1高字节
sfr T4T3M = 0xD1; //0000,0000 T3/T4模式寄存器
sfr T3T4M = 0xD1; //0000,0000 T3/T4模式寄存器
sfr T4H = 0xD2; //0000,0000 T4高字节
sfr T4L = 0xD3; //0000,0000 T4低字节
sfr T3H = 0xD4; //0000,0000 T3高字节
sfr T3L = 0xD5; //0000,0000 T3低字节
sfr T2H = 0xD6; //0000,0000 T2高字节
sfr T2L = 0xD7; //0000,0000 T2低字节
sfr WKTCL = 0xAA; //0000,0000 掉电唤醒定时器低字节
sfr WKTCH = 0xAB; //0000,0000 掉电唤醒定时器高字节
sfr WDT_CONTR = 0xC1; //0000,0000 看门狗控制寄存器
//串行口特殊功能寄存器
sfr SCON = 0x98; //0000,0000 串口1控制寄存器
sbit SM0 = SCON^7;
sbit SM1 = SCON^6;
sbit SM2 = SCON^5;
sbit REN = SCON^4;
sbit TB8 = SCON^3;
sbit RB8 = SCON^2;
sbit TI = SCON^1;
sbit RI = SCON^0;
sfr SBUF = 0x99; //xxxx,xxxx 串口1数据寄存器
sfr S2CON = 0x9A; //0000,0000 串口2控制寄存器
sfr S2BUF = 0x9B; //xxxx,xxxx 串口2数据寄存器
sfr S3CON = 0xAC; //0000,0000 串口3控制寄存器
sfr S3BUF = 0xAD; //xxxx,xxxx 串口3数据寄存器
sfr S4CON = 0x84; //0000,0000 串口4控制寄存器
sfr S4BUF = 0x85; //xxxx,xxxx 串口4数据寄存器
sfr SADDR = 0xA9; //0000,0000 从机地址寄存器
sfr SADEN = 0xB9; //0000,0000 从机地址屏蔽寄存器
//ADC 特殊功能寄存器
sfr ADC_CONTR = 0xBC; //0000,0000 A/D转换控制寄存器
sfr ADC_RES = 0xBD; //0000,0000 A/D转换结果高8位
sfr ADC_RESL = 0xBE; //0000,0000 A/D转换结果低2位
//SPI 特殊功能寄存器
sfr SPSTAT = 0xCD; //00xx,xxxx SPI状态寄存器
sfr SPCTL = 0xCE; //0000,0100 SPI控制寄存器
sfr SPDAT = 0xCF; //0000,0000 SPI数据寄存器
//IAP/ISP 特殊功能寄存器
sfr IAP_DATA = 0xC2; //0000,0000 EEPROM数据寄存器
sfr IAP_ADDRH = 0xC3; //0000,0000 EEPROM地址高字节
sfr IAP_ADDRL = 0xC4; //0000,0000 EEPROM地址第字节
sfr IAP_CMD = 0xC5; //xxxx,xx00 EEPROM命令寄存器
sfr IAP_TRIG = 0xC6; //0000,0000 EEPRPM命令触发寄存器
sfr IAP_CONTR = 0xC7; //0000,x000 EEPROM控制寄存器
//PCA/PWM 特殊功能寄存器
sfr CCON = 0xD8; //00xx,xx00 PCA控制寄存器
sbit CF = CCON^7;
sbit CR = CCON^6;
sbit CCF2 = CCON^2;
sbit CCF1 = CCON^1;
sbit CCF0 = CCON^0;
sfr CMOD = 0xD9; //0xxx,x000 PCA 工作模式寄存器
sfr CL = 0xE9; //0000,0000 PCA计数器低字节
sfr CH = 0xF9; //0000,0000 PCA计数器高字节
sfr CCAPM0 = 0xDA; //0000,0000 PCA模块0的PWM寄存器
sfr CCAPM1 = 0xDB; //0000,0000 PCA模块1的PWM寄存器
sfr CCAPM2 = 0xDC; //0000,0000 PCA模块2的PWM 寄存器
sfr CCAP0L = 0xEA; //0000,0000 PCA模块0的捕捉/比较寄存器低字节
sfr CCAP1L = 0xEB; //0000,0000 PCA模块1的捕捉/比较寄存器低字节
sfr CCAP2L = 0xEC; //0000,0000 PCA模块2的捕捉/比较寄存器低字节
sfr PCA_PWM0 = 0xF2; //xxxx,xx00 PCA模块0的PWM寄存器
sfr PCA_PWM1 = 0xF3; //xxxx,xx00 PCA模块1的PWM寄存器
sfr PCA_PWM2 = 0xF4; //xxxx,xx00 PCA模块1的PWM寄存器
sfr CCAP0H = 0xFA; //0000,0000 PCA模块0的捕捉/比较寄存器高字节
sfr CCAP1H = 0xFB; //0000,0000 PCA模块1的捕捉/比较寄存器高字节
sfr CCAP2H = 0xFC; //0000,0000 PCA模块2的捕捉/比较寄存器高字节
//比较器特殊功能寄存器
sfr CMPCR1 = 0xE6; //0000,0000 比较器控制寄存器1
sfr CMPCR2 = 0xE7; //0000,0000 比较器控制寄存器2
//增强型PWM波形发生器特殊功能寄存器
sfr PWMCFG = 0xf1; //x000,0000 PWM配置寄存器
sfr PWMCR = 0xf5; //0000,0000 PWM控制寄存器
sfr PWMIF = 0xf6; //x000,0000 PWM中断标志寄存器
sfr PWMFDCR = 0xf7; //xx00,0000 PWM外部异常检测控制寄存器
//如下特殊功能寄存器位于扩展RAM区域
//访问这些寄存器,需先将P_SW2的BIT7设置为1,才可正常读写
#define PWMC (*(unsigned int volatile xdata *)0xfff0)
#define PWMCH (*(unsigned char volatile xdata *)0xfff0)
#define PWMCL (*(unsigned char volatile xdata *)0xfff1)
#define PWMCKS (*(unsigned char volatile xdata *)0xfff2)
#define PWM2T1 (*(unsigned int volatile xdata *)0xff00)
#define PWM2T1H (*(unsigned char volatile xdata *)0xff00)
#define PWM2T1L (*(unsigned char volatile xdata *)0xff01)
#define PWM2T2 (*(unsigned int volatile xdata *)0xff02)
#define PWM2T2H (*(unsigned char volatile xdata *)0xff02)
#define PWM2T2L (*(unsigned char volatile xdata *)0xff03)
#define PWM2CR (*(unsigned char volatile xdata *)0xff04)
#define PWM3T1 (*(unsigned int volatile xdata *)0xff10)
#define PWM3T1H (*(unsigned char volatile xdata *)0xff10)
#define PWM3T1L (*(unsigned char volatile xdata *)0xff11)
#define PWM3T2 (*(unsigned int volatile xdata *)0xff12)
#define PWM3T2H (*(unsigned char volatile xdata *)0xff12)
#define PWM3T2L (*(unsigned char volatile xdata *)0xff13)
#define PWM3CR (*(unsigned char volatile xdata *)0xff14)
#define PWM4T1 (*(unsigned int volatile xdata *)0xff20)
#define PWM4T1H (*(unsigned char volatile xdata *)0xff20)
#define PWM4T1L (*(unsigned char volatile xdata *)0xff21)
#define PWM4T2 (*(unsigned int volatile xdata *)0xff22)
#define PWM4T2H (*(unsigned char volatile xdata *)0xff22)
#define PWM4T2L (*(unsigned char volatile xdata *)0xff23)
#define PWM4CR (*(unsigned char volatile xdata *)0xff24)
#define PWM5T1 (*(unsigned int volatile xdata *)0xff30)
#define PWM5T1H (*(unsigned char volatile xdata *)0xff30)
#define PWM5T1L (*(unsigned char volatile xdata *)0xff31)
#define PWM5T2 (*(unsigned int volatile xdata *)0xff32)
#define PWM5T2H (*(unsigned char volatile xdata *)0xff32)
#define PWM5T2L (*(unsigned char volatile xdata *)0xff33)
#define PWM5CR (*(unsigned char volatile xdata *)0xff34)
#define PWM6T1 (*(unsigned int volatile xdata *)0xff40)
#define PWM6T1H (*(unsigned char volatile xdata *)0xff40)
#define PWM6T1L (*(unsigned char volatile xdata *)0xff41)
#define PWM6T2 (*(unsigned int volatile xdata *)0xff42)
#define PWM6T2H (*(unsigned char volatile xdata *)0xff42)
#define PWM6T2L (*(unsigned char volatile xdata *)0xff43)
#define PWM6CR (*(unsigned char volatile xdata *)0xff44)
#define PWM7T1 (*(unsigned int volatile xdata *)0xff50)
#define PWM7T1H (*(unsigned char volatile xdata *)0xff50)
#define PWM7T1L (*(unsigned char volatile xdata *)0xff51)
#define PWM7T2 (*(unsigned int volatile xdata *)0xff52)
#define PWM7T2H (*(unsigned char volatile xdata *)0xff52)
#define PWM7T2L (*(unsigned char volatile xdata *)0xff53)
#define PWM7CR (*(unsigned char volatile xdata *)0xff54)
/
#endif