STC15W408AS library
0.9.0
include
STC15Fxx.h
1
#ifndef STC15Fxx_H
2
#define STC15Fxx_H
3
4
#include <compiler.h>
5
6
// 包含本头文件后,不用另外再包含"REG51.H"
7
// 适用于 STC15Wxx / STC15Fxx 系列的芯片
8
// Modified based on STC-ISP version by: ZnHoCn
9
11
//注意: STC15W4K32S4系列的芯片,上电后所有与PWM相关的IO口均为
12
// 高阻态,需将这些口设置为准双向口或强推挽模式方可正常使用
13
//相关IO: P0.6/P0.7/P1.6/P1.7/P2.1/P2.2
14
// P2.3/P2.7/P3.7/P4.2/P4.4/P4.5
16
17
//内核特殊功能寄存器 //复位值 描述
18
#define _ACC 0xE0
19
SFR(ACC, 0xE0);
//0000,0000 累加器Accumulator
20
#define _B 0xF0
21
SFR(B, 0xF0);
//0000,0000 B寄存器
22
#define _PSW 0xD0
23
SFR(PSW, 0xD0);
//0000,0000 程序状态字
24
SBIT(CY, _PSW, 7);
25
SBIT(AC, _PSW, 6);
26
SBIT(F0, _PSW, 5);
27
SBIT(RS1, _PSW, 4);
28
SBIT(RS0, _PSW, 3);
29
SBIT(OV, _PSW, 2);
30
SBIT(F1, _PSW, 1);
31
SBIT(P, _PSW, 0);
32
#define _SP 0x81
33
SFR(SP, 0x81);
//0000,0111 堆栈指针
34
#define _DPL 0x82
35
SFR(DPL, 0x82);
//0000,0000 数据指针低字节
36
#define _DPH 0x83
37
SFR(DPH, 0x83);
//0000,0000 数据指针高字节
38
39
//I/O 口特殊功能寄存器
40
#define _P0 0x80
41
SFR(P0, 0x80);
//1111,1111 端口0
42
SBIT(P00, _P0, 0);
43
SBIT(P01, _P0, 1);
44
SBIT(P02, _P0, 2);
45
SBIT(P03, _P0, 3);
46
SBIT(P04, _P0, 4);
47
SBIT(P05, _P0, 5);
48
SBIT(P06, _P0, 6);
49
SBIT(P07, _P0, 7);
50
#define _P1 0x90
51
SFR(P1, 0x90);
//1111,1111 端口1
52
SBIT(P10, _P1, 0);
53
SBIT(P11, _P1, 1);
54
SBIT(P12, _P1, 2);
55
SBIT(P13, _P1, 3);
56
SBIT(P14, _P1, 4);
57
SBIT(P15, _P1, 5);
58
SBIT(P16, _P1, 6);
59
SBIT(P17, _P1, 7);
60
#define _P2 0xA0
61
SFR(P2, 0xA0);
//1111,1111 端口2
62
SBIT(P20, _P2, 0);
63
SBIT(P21, _P2, 1);
64
SBIT(P22, _P2, 2);
65
SBIT(P23, _P2, 3);
66
SBIT(P24, _P2, 4);
67
SBIT(P25, _P2, 5);
68
SBIT(P26, _P2, 6);
69
SBIT(P27, _P2, 7);
70
#define _P3 0xB0
71
SFR(P3, 0xB0);
//1111,1111 端口3
72
SBIT(P30, _P3, 0);
73
SBIT(P31, _P3, 1);
74
SBIT(P32, _P3, 2);
75
SBIT(P33, _P3, 3);
76
SBIT(P34, _P3, 4);
77
SBIT(P35, _P3, 5);
78
SBIT(P36, _P3, 6);
79
SBIT(P37, _P3, 7);
80
#define _P4 0xC0
81
SFR(P4, 0xC0);
//1111,1111 端口4
82
SBIT(P40, _P4, 0);
83
SBIT(P41, _P4, 1);
84
SBIT(P42, _P4, 2);
85
SBIT(P43, _P4, 3);
86
SBIT(P44, _P4, 4);
87
SBIT(P45, _P4, 5);
88
SBIT(P46, _P4, 6);
89
SBIT(P47, _P4, 7);
90
#define _P5 0xC8
91
SFR(P5, 0xC8);
//xxxx,1111 端口5
92
SBIT(P50, _P5, 0);
93
SBIT(P51, _P5, 1);
94
SBIT(P52, _P5, 2);
95
SBIT(P53, _P5, 3);
96
SBIT(P54, _P5, 4);
97
SBIT(P55, _P5, 5);
98
SBIT(P56, _P5, 6);
99
SBIT(P57, _P5, 7);
100
#define _P6 0xE8
101
SFR(P6, 0xE8);
//0000,0000 端口6
102
SBIT(P60, _P6, 0);
103
SBIT(P61, _P6, 1);
104
SBIT(P62, _P6, 2);
105
SBIT(P63, _P6, 3);
106
SBIT(P64, _P6, 4);
107
SBIT(P65, _P6, 5);
108
SBIT(P66, _P6, 6);
109
SBIT(P67, _P6, 7);
110
#define _P7 0xF8
111
SFR(P7, 0xF8);
//0000,0000 端口7
112
SBIT(P70, _P7, 0);
113
SBIT(P71, _P7, 1);
114
SBIT(P72, _P7, 2);
115
SBIT(P73, _P7, 3);
116
SBIT(P74, _P7, 4);
117
SBIT(P75, _P7, 5);
118
SBIT(P76, _P7, 6);
119
SBIT(P77, _P7, 7);
120
121
#define _P0M0 0x94
122
SFR(P0M0, 0x94);
//0000,0000 端口0模式寄存器0
123
#define _P0M1 0x93
124
SFR(P0M1, 0x93);
//0000,0000 端口0模式寄存器1
125
#define _P1M0 0x92
126
SFR(P1M0, 0x92);
//0000,0000 端口1模式寄存器0
127
#define _P1M1 0x91
128
SFR(P1M1, 0x91);
//0000,0000 端口1模式寄存器1
129
#define _P2M0 0x96
130
SFR(P2M0, 0x96);
//0000,0000 端口2模式寄存器0
131
#define _P2M1 0x95
132
SFR(P2M1, 0x95);
//0000,0000 端口2模式寄存器1
133
#define _P3M0 0xB2
134
SFR(P3M0, 0xB2);
//0000,0000 端口3模式寄存器0
135
#define _P3M1 0xB1
136
SFR(P3M1, 0xB1);
//0000,0000 端口3模式寄存器1
137
#define _P4M0 0xB4
138
SFR(P4M0, 0xB4);
//0000,0000 端口4模式寄存器0
139
#define _P4M1 0xB3
140
SFR(P4M1, 0xB3);
//0000,0000 端口4模式寄存器1
141
#define _P5M0 0xCA
142
SFR(P5M0, 0xCA);
//0000,0000 端口5模式寄存器0
143
#define _P5M1 0xC9
144
SFR(P5M1, 0xC9);
//0000,0000 端口5模式寄存器1
145
#define _P6M0 0xCC
146
SFR(P6M0, 0xCC);
//0000,0000 端口6模式寄存器0
147
#define _P6M1 0xCB
148
SFR(P6M1, 0xCB);
//0000,0000 端口6模式寄存器1
149
#define _P7M0 0xE2
150
SFR(P7M0, 0xE2);
//0000,0000 端口7模式寄存器0
151
#define _P7M1 0xE1
152
SFR(P7M1, 0xE1);
//0000,0000 端口7模式寄存器1
153
154
//系统管理特殊功能寄存器
155
#define _PCON 0x87
156
SFR(PCON, 0x87);
//0001,0000 电源控制寄存器
157
#define _AUXR 0x8E
158
SFR(AUXR, 0x8E);
//0000,0000 辅助寄存器
159
#define _AUXR1 0xA2
160
SFR(AUXR1, 0xA2);
//0000,0000 辅助寄存器1
161
#define _P_SW1 0xA2
162
SFR(P_SW1, 0xA2);
//0000,0000 外设端口切换寄存器1
163
#define _CLK_DIV 0x97
164
SFR(CLK_DIV, 0x97);
//0000,0000 时钟分频控制寄存器
165
#define _BUS_SPEED 0xA1
166
SFR(BUS_SPEED, 0xA1);
//xx10,x011 总线速度控制寄存器
167
#define _P1ASF 0x9D
168
SFR(P1ASF, 0x9D);
//0000,0000 端口1模拟功能配置寄存器
169
#define _P_SW2 0xBA
170
SFR(P_SW2, 0xBA);
//0xxx,x000 外设端口切换寄存器
171
172
//中断特殊功能寄存器
173
#define _IE 0xA8
174
SFR(IE, 0xA8);
//0000,0000 中断控制寄存器
175
SBIT(EA, _IE, 7);
176
SBIT(ELVD, _IE, 6);
177
SBIT(EADC, _IE, 5);
178
SBIT(ES, _IE, 4);
179
SBIT(ET1, _IE, 3);
180
SBIT(EX1, _IE, 2);
181
SBIT(ET0, _IE, 1);
182
SBIT(EX0, _IE, 0);
183
#define _IP 0xB8
184
SFR(IP, 0xB8);
//0000,0000 中断优先级寄存器
185
SBIT(PPCA, _IP, 7);
186
SBIT(PLVD, _IP, 6);
187
SBIT(PADC, _IP, 5);
188
SBIT(PS, _IP, 4);
189
SBIT(PT1, _IP, 3);
190
SBIT(PX1, _IP, 2);
191
SBIT(PT0, _IP, 1);
192
SBIT(PX0, _IP, 0);
193
#define _IE2 0xAF
194
SFR(IE2, 0xAF);
//0000,0000 中断控制寄存器2
195
#define _IP2 0xB5
196
SFR(IP2, 0xB5);
//xxxx,xx00 中断优先级寄存器2
197
#define _INT_CLKO 0x8F
198
SFR(INT_CLKO, 0x8F);
//0000,0000 外部中断与时钟输出控制寄存器
199
200
//定时器特殊功能寄存器
201
#define _TCON 0x88
202
SFR(TCON, 0x88);
//0000,0000 T0/T1控制寄存器
203
SBIT(TF1, _TCON, 7);
204
SBIT(TR1, _TCON, 6);
205
SBIT(TF0, _TCON, 5);
206
SBIT(TR0, _TCON, 4);
207
SBIT(IE1, _TCON, 3);
208
SBIT(IT1, _TCON, 2);
209
SBIT(IE0, _TCON, 1);
210
SBIT(IT0, _TCON, 0);
211
#define _TMOD 0x89
212
SFR(TMOD, 0x89);
//0000,0000 T0/T1模式寄存器
213
#define _TL0 0x8A
214
SFR(TL0, 0x8A);
//0000,0000 T0低字节
215
#define _TL1 0x8B
216
SFR(TL1, 0x8B);
//0000,0000 T1低字节
217
#define _TH0 0x8C
218
SFR(TH0, 0x8C);
//0000,0000 T0高字节
219
#define _TH1 0x8D
220
SFR(TH1, 0x8D);
//0000,0000 T1高字节
221
#define _T4T3M 0xD1
222
SFR(T4T3M, 0xD1);
//0000,0000 T3/T4模式寄存器
223
// #default _T3T4M 0xD1
224
// SFR(T3T4M, 0xD1); //0000,0000 T3/T4模式寄存器
225
#define _T4H 0xD2
226
SFR(T4H, 0xD2);
//0000,0000 T4高字节
227
#define _T4L 0xD3
228
SFR(T4L, 0xD3);
//0000,0000 T4低字节
229
#define _T3H 0xD4
230
SFR(T3H, 0xD4);
//0000,0000 T3高字节
231
#define _T3L 0xD5
232
SFR(T3L, 0xD5);
//0000,0000 T3低字节
233
#define _T2H 0xD6
234
SFR(T2H, 0xD6);
//0000,0000 T2高字节
235
#define _T2L 0xD7
236
SFR(T2L, 0xD7);
//0000,0000 T2低字节
237
#define _WKTCL 0xAA
238
SFR(WKTCL, 0xAA);
//0000,0000 掉电唤醒定时器低字节
239
#define _WKTCH 0xAB
240
SFR(WKTCH, 0xAB);
//0000,0000 掉电唤醒定时器高字节
241
#define _WDT_CONTR 0xC1
242
SFR(WDT_CONTR, 0xC1);
//0000,0000 看门狗控制寄存器
243
244
//串行口特殊功能寄存器
245
#define _SCON 0x98
246
SFR(SCON, 0x98);
//0000,0000 串口1控制寄存器
247
SBIT(SM0, _SCON, 7);
248
SBIT(SM1, _SCON, 6);
249
SBIT(SM2, _SCON, 5);
250
SBIT(REN, _SCON, 4);
251
SBIT(TB8, _SCON, 3);
252
SBIT(RB8, _SCON, 2);
253
SBIT(TI, _SCON, 1);
254
SBIT(RI, _SCON, 0);
255
#define _SBUF 0x99
256
SFR(SBUF, 0x99);
//xxxx,xxxx 串口1数据寄存器
257
#define _S2CON 0x9A
258
SFR(S2CON, 0x9A);
//0000,0000 串口2控制寄存器
259
#define _S2BUF 0x9B
260
SFR(S2BUF, 0x9B);
//xxxx,xxxx 串口2数据寄存器
261
#define _S3CON 0xAC
262
SFR(S3CON, 0xAC);
//0000,0000 串口3控制寄存器
263
#define _S3BUF 0xAD
264
SFR(S3BUF, 0xAD);
//xxxx,xxxx 串口3数据寄存器
265
#define _S4CON 0x84
266
SFR(S4CON, 0x84);
//0000,0000 串口4控制寄存器
267
#define _S4BUF 0x85
268
SFR(S4BUF, 0x85);
//xxxx,xxxx 串口4数据寄存器
269
#define _SADDR 0xA9
270
SFR(SADDR, 0xA9);
//0000,0000 从机地址寄存器
271
#define _SADEN 0xB9
272
SFR(SADEN, 0xB9);
//0000,0000 从机地址屏蔽寄存器
273
274
//ADC 特殊功能寄存器
275
#define _ADC_CONTR 0xBC
276
SFR(ADC_CONTR, 0xBC);
//0000,0000 A/D转换控制寄存器
277
#define _ADC_RES 0xBD
278
SFR(ADC_RES, 0xBD);
//0000,0000 A/D转换结果高8位
279
#define _ADC_RESL 0xBE
280
SFR(ADC_RESL, 0xBE);
//0000,0000 A/D转换结果低2位
281
282
//SPI 特殊功能寄存器
283
#define _SPSTAT 0xCD
284
SFR(SPSTAT, 0xCD);
//00xx,xxxx SPI状态寄存器
285
#define _SPCTL 0xCE
286
SFR(SPCTL, 0xCE);
//0000,0100 SPI控制寄存器
287
#define _SPDAT 0xCF
288
SFR(SPDAT, 0xCF);
//0000,0000 SPI数据寄存器
289
290
//IAP/ISP 特殊功能寄存器
291
#define _IAP_DATA 0xC2
292
SFR(IAP_DATA, 0xC2);
//0000,0000 EEPROM数据寄存器
293
#define _IAP_ADDRH 0xC3
294
SFR(IAP_ADDRH, 0xC3);
//0000,0000 EEPROM地址高字节
295
#define _IAP_ADDRL 0xC4
296
SFR(IAP_ADDRL, 0xC4);
//0000,0000 EEPROM地址第字节
297
#define _IAP_CMD 0xC5
298
SFR(IAP_CMD, 0xC5);
//xxxx,xx00 EEPROM命令寄存器
299
#define _IAP_TRIG 0xC6
300
SFR(IAP_TRIG, 0xC6);
//0000,0000 EEPRPM命令触发寄存器
301
#define _IAP_CONTR 0xC7
302
SFR(IAP_CONTR, 0xC7);
//0000,x000 EEPROM控制寄存器
303
304
//PCA/PWM 特殊功能寄存器
305
#define _CCON 0xD8
306
SFR(CCON, 0xD8);
//00xx,xx00 PCA控制寄存器
307
SBIT(CF, _CCON, 7);
308
SBIT(CR, _CCON, 6);
309
SBIT(CCF2, _CCON, 2);
310
SBIT(CCF1, _CCON, 1);
311
SBIT(CCF0, _CCON, 0);
312
#define _CMOD 0xD9
313
SFR(CMOD, 0xD9);
//0xxx,x000 PCA 工作模式寄存器
314
#define _CL 0xE9
315
SFR(CL, 0xE9);
//0000,0000 PCA计数器低字节
316
#define _CH 0xF9
317
SFR(CH, 0xF9);
//0000,0000 PCA计数器高字节
318
#define _CCAPM0 0xDA
319
SFR(CCAPM0, 0xDA);
//0000,0000 PCA模块0的PWM寄存器
320
#define _CCAPM1 0xDB
321
SFR(CCAPM1, 0xDB);
//0000,0000 PCA模块1的PWM寄存器
322
#define _CCAPM2 0xDC
323
SFR(CCAPM2, 0xDC);
//0000,0000 PCA模块2的PWM 寄存器
324
#define _CCAP0L 0xEA
325
SFR(CCAP0L, 0xEA);
//0000,0000 PCA模块0的捕捉/比较寄存器低字节
326
#define _CCAP1L 0xEB
327
SFR(CCAP1L, 0xEB);
//0000,0000 PCA模块1的捕捉/比较寄存器低字节
328
#define _CCAP2L 0xEC
329
SFR(CCAP2L, 0xEC);
//0000,0000 PCA模块2的捕捉/比较寄存器低字节
330
#define _PCA_PWM0 0xF2
331
SFR(PCA_PWM0, 0xF2);
//xxxx,xx00 PCA模块0的PWM寄存器
332
#define _PCA_PWM1 0xF3
333
SFR(PCA_PWM1, 0xF3);
//xxxx,xx00 PCA模块1的PWM寄存器
334
#define _PCA_PWM2 0xF4
335
SFR(PCA_PWM2, 0xF4);
//xxxx,xx00 PCA模块1的PWM寄存器
336
#define _CCAP0H 0xFA
337
SFR(CCAP0H, 0xFA);
//0000,0000 PCA模块0的捕捉/比较寄存器高字节
338
#define _CCAP1H 0xFB
339
SFR(CCAP1H, 0xFB);
//0000,0000 PCA模块1的捕捉/比较寄存器高字节
340
#define _CCAP2H 0xFC
341
SFR(CCAP2H, 0xFC);
//0000,0000 PCA模块2的捕捉/比较寄存器高字节
342
343
//比较器特殊功能寄存器
344
#define _CMPCR1 0xE6
345
SFR(CMPCR1, 0xE6);
//0000,0000 比较器控制寄存器1
346
#define _CMPCR2 0xE7
347
SFR(CMPCR2, 0xE7);
//0000,0000 比较器控制寄存器2
348
349
//增强型PWM波形发生器特殊功能寄存器
350
#define _PWMCFG 0xF1
351
SFR(PWMCFG, 0xF1);
//x000,0000 PWM配置寄存器
352
#define _PWMCR 0xF5
353
SFR(PWMCR, 0xF5);
//0000,0000 PWM控制寄存器
354
#define _PWMIF 0xF6
355
SFR(PWMIF, 0xF6);
//x000,0000 PWM中断标志寄存器
356
#define _PWMFDCR 0xF7
357
SFR(PWMFDCR, 0xF7);
//xx00,0000 PWM外部异常检测控制寄存器
358
359
//如下特殊功能寄存器位于扩展RAM区域
360
//访问这些寄存器,需先将P_SW2的BIT7设置为1,才可正常读写
361
#define PWMC (*(unsigned int volatile xdata *)0xfff0)
362
#define PWMCH (*(unsigned char volatile xdata *)0xfff0)
363
#define PWMCL (*(unsigned char volatile xdata *)0xfff1)
364
#define PWMCKS (*(unsigned char volatile xdata *)0xfff2)
365
#define PWM2T1 (*(unsigned int volatile xdata *)0xff00)
366
#define PWM2T1H (*(unsigned char volatile xdata *)0xff00)
367
#define PWM2T1L (*(unsigned char volatile xdata *)0xff01)
368
#define PWM2T2 (*(unsigned int volatile xdata *)0xff02)
369
#define PWM2T2H (*(unsigned char volatile xdata *)0xff02)
370
#define PWM2T2L (*(unsigned char volatile xdata *)0xff03)
371
#define PWM2CR (*(unsigned char volatile xdata *)0xff04)
372
#define PWM3T1 (*(unsigned int volatile xdata *)0xff10)
373
#define PWM3T1H (*(unsigned char volatile xdata *)0xff10)
374
#define PWM3T1L (*(unsigned char volatile xdata *)0xff11)
375
#define PWM3T2 (*(unsigned int volatile xdata *)0xff12)
376
#define PWM3T2H (*(unsigned char volatile xdata *)0xff12)
377
#define PWM3T2L (*(unsigned char volatile xdata *)0xff13)
378
#define PWM3CR (*(unsigned char volatile xdata *)0xff14)
379
#define PWM4T1 (*(unsigned int volatile xdata *)0xff20)
380
#define PWM4T1H (*(unsigned char volatile xdata *)0xff20)
381
#define PWM4T1L (*(unsigned char volatile xdata *)0xff21)
382
#define PWM4T2 (*(unsigned int volatile xdata *)0xff22)
383
#define PWM4T2H (*(unsigned char volatile xdata *)0xff22)
384
#define PWM4T2L (*(unsigned char volatile xdata *)0xff23)
385
#define PWM4CR (*(unsigned char volatile xdata *)0xff24)
386
#define PWM5T1 (*(unsigned int volatile xdata *)0xff30)
387
#define PWM5T1H (*(unsigned char volatile xdata *)0xff30)
388
#define PWM5T1L (*(unsigned char volatile xdata *)0xff31)
389
#define PWM5T2 (*(unsigned int volatile xdata *)0xff32)
390
#define PWM5T2H (*(unsigned char volatile xdata *)0xff32)
391
#define PWM5T2L (*(unsigned char volatile xdata *)0xff33)
392
#define PWM5CR (*(unsigned char volatile xdata *)0xff34)
393
#define PWM6T1 (*(unsigned int volatile xdata *)0xff40)
394
#define PWM6T1H (*(unsigned char volatile xdata *)0xff40)
395
#define PWM6T1L (*(unsigned char volatile xdata *)0xff41)
396
#define PWM6T2 (*(unsigned int volatile xdata *)0xff42)
397
#define PWM6T2H (*(unsigned char volatile xdata *)0xff42)
398
#define PWM6T2L (*(unsigned char volatile xdata *)0xff43)
399
#define PWM6CR (*(unsigned char volatile xdata *)0xff44)
400
#define PWM7T1 (*(unsigned int volatile xdata *)0xff50)
401
#define PWM7T1H (*(unsigned char volatile xdata *)0xff50)
402
#define PWM7T1L (*(unsigned char volatile xdata *)0xff51)
403
#define PWM7T2 (*(unsigned int volatile xdata *)0xff52)
404
#define PWM7T2H (*(unsigned char volatile xdata *)0xff52)
405
#define PWM7T2L (*(unsigned char volatile xdata *)0xff53)
406
#define PWM7CR (*(unsigned char volatile xdata *)0xff54)
407
408
#endif
Generated by
1.9.4