📄 timer.lst
字号:
C51 COMPILER V7.02b TIMER 06/20/2006 18:46:34 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE TIMER
OBJECT MODULE PLACED IN timer.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE timer.c DEBUG OBJECTEXTEND
stmt level source
1 /*-------------------------------------*/
2 /*
3 THIS FOR TIMER SUBROUTINE USEED
4 TO SET TIMER TO 4S, 60S, 10MS, &INTERRUPT WITH THE TIMEERS
5
6 */
7 /*-------------------------------------*/
8 /*
9 this routine to use the timer & respone timer interrupt
10
11
12 */
13 /*------------------------------------*/
14 #include "defineh.h"
15 #include "timer.h"
16 /*-----------------------------------*/
17 extern void Clr_Rx(void);
18 /*----------------------------------------*/
19
20 void init_timer2()
21 { // init the timer2 to 30ms to determine the answer-frame full or not, if not dompleted, delete it weat
-her a message frame.
22 1 //if not , free the comm line.if a message frame, count for 4s.if a right respone ,count 1min.
23 1 //NOT confirm the data
24 1 #if CRYSTALOID
{ //12MHZ
TH2=0x8a;
TL2=0xd0;
}
#else
30 1 {
31 2 TH2=0x94;
32 2 TL2=0x2f;
33 2 }
34 1 #endif
35 1
36 1 T2CON=0X03; /*timer enble,*/
37 1 T2MOD=0x01; /*timer reload mode*/
38 1 timeout2=0;
39 1
40 1 T2CON=0;
41 1 ET2=1;
42 1 TR2=1;
43 1
44 1 }
45 /*------------------------------------------*/
46 /* INIT TIMER0
47 Description:
48 timer0 use to count 3ms once a time, to determine a data received
49
50
51 */
52
53 /*-----------------------------------------------*/
54 void init_timer0(void)
C51 COMPILER V7.02b TIMER 06/20/2006 18:46:34 PAGE 2
55 {
56 1 //TMOD=0x21; //*定时器0工作方式1,16位定时
57 1 #if CRYSTALOID //定时器该为3ms定时
{ //12MHZ
TH0=0xfC; //TH0=0xf4; //3MS
TL0=0x18; //TL0=0x48;
}
#else
64 1 {
65 2 TH0=0xf5;
66 2 TL0=0x50;
67 2 }
68 1 #endif
69 1
70 1 TR0=1; //To enable bit
71 1 ET0=1; //open To,enable it interrupt
72 1 timeout0=0;
73 1 }
74 /*-------------------------------------------*/
75 /* every received must less than 2ms,if a receiving action not wrong,
76 when finished a receiving,clr the timer0
77
78
79 */
80 /*--------------------------------------------*/
81 void timer0_out() interrupt 1
82 {
83 1 TF0=0;
84 1
85 1 if(Rxrun_bit)
86 1 {
87 2 if(Rx_count>timeout0) //not late the data
88 2 {
89 3 timeout0=Rx_count;
90 3
91 3 #if CRYSTALOID //定时器该为1ms定时
{ //12MHZ
TH0=0xfC; //TH0=0xf4; //1MS
TL0=0x18; //TL0=0x48;
}
#else
98 3 {
99 4 TH0=0xf5;
100 4 TL0=0x50;
101 4 }
102 3 #endif
103 3 }
104 2 else
105 2 {
106 3 Clr_Rx();
107 3 TR0=0;
108 3 }
109 2 }
110 1 else //rx finish
111 1 {
112 2 TR0=0;
113 2 }
114 1 }
115 /*--------------------------------------------*/
116 /*
C51 COMPILER V7.02b TIMER 06/20/2006 18:46:34 PAGE 3
117 timer2 count 1s, if lower than 15 bytes, the datas valid & not a message frame
118 if rx_count more than 16 byte, must be a message frames or a bad frame
119 And, timeout2 cout 25 times for 1s
120 timeout1 count for the cycle
121 */
122 /*-------------------------------------------*/
123 void timer2_out() interrupt 5
124 {
125 1 TF2=0;
126 1 timeout2++;
127 1 }
128 /*---------------------------------------------*/
129 void clr_timer2(void)
130 {
131 1
132 1 T2CON=0X00;
133 1 T2MOD=0x00;
134 1 TR2=0;
135 1
136 1 TL2=0;
137 1 TH2=0;
138 1 timeout2=0;
139 1
140 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 157 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -