提交 | 用户 | age
|
5dd1b7
|
1 |
#include "STC15F2K60S2.H" |
Q |
2 |
|
|
3 |
|
|
4 |
void Timer0_Isr(void) interrupt 1 |
|
5 |
{ |
|
6 |
} |
|
7 |
|
|
8 |
void Timer0_Init(void) //125微秒@22.1184MHz |
|
9 |
{ |
|
10 |
AUXR |= 0x80; //定时器时钟1T模式 |
|
11 |
TMOD &= 0xF0; //设置定时器模式 |
|
12 |
TL0 = 0x33; //设置定时初始值 |
|
13 |
TH0 = 0xF5; //设置定时初始值 |
|
14 |
TF0 = 0; //清除TF0标志 |
|
15 |
TR0 = 1; //定时器0开始计时 |
|
16 |
ET0 = 1; //使能定时器0中断 |
|
17 |
} |
|
18 |
|
|
19 |
|
|
20 |
void Timer1_Isr(void) interrupt 3 |
|
21 |
{ |
|
22 |
} |
|
23 |
|
|
24 |
void Timer1_Init(void) //1毫秒@22.1184MHz |
|
25 |
{ |
|
26 |
AUXR |= 0x40; //定时器时钟1T模式 |
|
27 |
TMOD &= 0x0F; //设置定时器模式 |
|
28 |
TL1 = 0x9A; //设置定时初始值 |
|
29 |
TH1 = 0xA9; //设置定时初始值 |
|
30 |
TF1 = 0; //清除TF1标志 |
|
31 |
TR1 = 1; //定时器1开始计时 |
|
32 |
ET1 = 1; //使能定时器1中断 |
|
33 |
} |