📄 main.lst
字号:
C51 COMPILER V7.05 MAIN 04/08/2005 13:54:31 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include<REG922.h>
2 #include <absacc.h>
3 #include "string.h"
4 #include "intrins.h"
5
6 #include "ports.h"
7 #include "osc.h"
8 #include "uart.h"
9 #include "rtc.h"
10 #include "power.h"
11 #include "watchdogrtc.h "
12 #include "IAP_LITE.H"
13 #include "crc.h"
14 #include "keypad.h"
15 bit T_flag=0,set=0,set_ok;
16 bit beep_flg=0;
17
18 void Send_ok(unsigned char key);
19 unsigned char ADDR,RX_addr=0,key_tem=01;
20 unsigned char wring_send_times=0;
21
22 //************************程序用的变量********************
23 unsigned char data RXtem[7];//程序接收数据缓冲区
24 unsigned char data RXNOM,RXSTAT=0;
25 unsigned char data RXTimerOUT,i,RX_BEEP=0; //接收超时
26 bit rxok; // 接收完成标志
27
28 unsigned int xxxx,beep_delay=0;
29 /****************************************************************************/
30 union charint{
31 unsigned char chrX[2];
32 unsigned int intX;
33 };
34
35 union charint data CRC;
36
37 void Delay100ms(unsigned char x)
38 {
39 1 unsigned char i,j;
40 1
41 1 while(x-- != 0)
42 1 {
43 2
44 2 for (j = 0;j < 114; j++)
45 2 {
46 3 if(rxok)
47 3 {
48 4 rxok=0;
49 4 Send_ok(key_tem);
50 4 i=0;
51 4 }
52 3 for (i = 0;i < 88; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
53 4 _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
-) ;
54 4 _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
C51 COMPILER V7.05 MAIN 04/08/2005 13:54:31 PAGE 2
-) ;
55 4 _nop_() ;_nop_() ;_nop_() ;};
56 3 }
57 2 }
58 1 }
59
60 /****************************************************************************/
61
62
63 void Delay1ms(unsigned char idata x)
64 {
65 1 unsigned char i;
66 1
67 1 while(x-- != 0)
68 1 {
69 2 if(rxok)
70 2 {
71 3 rxok=0;
72 3 Send_ok(key_tem);
73 3 i=0;
74 3 }
75 2 for (i = 0;i < 89; i++){_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;
76 3 _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
-) ;
77 3 _nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_() ;_nop_(
-) ;
78 3 _nop_() ;_nop_() ;_nop_() ;};
79 2 }
80 1 }
81
82 /***********************************************************************
83 DESC: Initializes UART for mode 1
84 Baudrate: 9600
85 RETURNS: Nothing
86 CAUTION: If interrupts are being used then EA must be set to 1
87 after calling this function
88 ************************************************************************/
89 void uart_init(void)
90 {
91 1 // configure UART
92 1 // clear SMOD0
93 1 PCON &= ~0x40;
94 1 SCON = 0x50;
95 1 // set or clear SMOD1
96 1 PCON &= 0x7f;
97 1 PCON |= (0 << 8);
98 1 SSTAT = 0x00;
99 1
100 1 // enable break detect
101 1 AUXR1 |= 0x40;
102 1
103 1 // configure baud rate generator
104 1 BRGCON = 0x00;
105 1 BRGR0 = 0xF0;
106 1 BRGR1 = 0x02;
107 1 BRGCON = 0x03;
108 1
109 1 // TxD = push-pull, RxD = input
110 1 P1M1 &= ~0x01;
111 1 P1M2 |= 0x01;
112 1 P1M1 |= 0x02;
113 1 P1M2 &= ~0x02;
C51 COMPILER V7.05 MAIN 04/08/2005 13:54:31 PAGE 3
114 1
115 1 // initially not busy
116 1
117 1
118 1 // set isr priority to 0
119 1 IP0 &= 0xEF;
120 1 IP0H &= 0xEF;
121 1 // enable uart interrupt
122 1 ES = 0;
123 1
124 1 } // uart_init
125 /***********************************************************************
126 DESC: Initializes the ports
127 RETURNS: Nothing
128 CAUTION: Call before the initialization functions of other peripherals
129 ************************************************************************/
130 void ports_init(void)
131 {
132 1 P0M1 &= 0xe0;
133 1 P0M2 &= 0xe0;
134 1
135 1 /*P1M1 |= 0x2C;
136 1 P1M2 &= 0xDF;
137 1 P1M2 |= 0x0C;*/
138 1 P1M1 &= 0xEC;
139 1 P1M1 |= 0x2C;
140 1 P1M2 &= 0xDF;
141 1 P1M2 |= 0x1F;
142 1
143 1
144 1 } // ports_init
145 //*******************add**********************************************
146
147
148 /****************************************************************************
149 * *
150 * Function: START_T0 *
151 * *
152 * Input: - *
153 * Output: - *
154 * *
155 * Description: *
156 * *
157 * *
158 ****************************************************************************/
159 void START_T0(unsigned char x)
160 {
161 1 ET0 = 0 ;
162 1 TR0 = 0;
163 1 RXTimerOUT = x ;
164 1 TL0 = 0;
165 1 TH0 = 0;
166 1 TR0 = 1;
167 1 ET0 = 1 ;
168 1 }
169 /****************************************************************************
170 * *
171 * Function: CALL_isr_T0 *
172 * *
173 * Input: - *
174 * Output: - *
175 * *
C51 COMPILER V7.05 MAIN 04/08/2005 13:54:31 PAGE 4
176 * Description: *
177 * *
178 * *
179 ****************************************************************************/
180 void CALL_isr_T0(void)
181 {
182 1 TR0 = 0;
183 1 RXTimerOUT = 0;
184 1 TF0 = 1;
185 1
186 1 }
187
188 //********************串口中断处理程序**************************************************************
189 void ub1ISR(void) interrupt 4 using 1
190 {
191 1 unsigned char c;
192 1 // unsigned int data crcx;
193 1 if ( RI ) // Receive Command
194 1 {
195 2 // RXTimerOUT=10;
196 2 RI = 0;
197 2 c = SBUF;
198 2
199 2 switch(RXSTAT)
200 2 {
201 3 case 0: //接受帧头02
202 3 if(c==0x55)
203 3 {RXSTAT=1;START_T0(20);RXtem[0]=c;}
204 3 else
205 3 CALL_isr_T0();
206 3 break;
207 3 case 1: //接收
208 3 if(c==0xaa)
209 3 {
210 4 RXSTAT=2;
211 4 START_T0(20);
212 4 RXtem[1]=c;
213 4 }
214 3 else
215 3 {
216 4 if(c==0xbb)
217 4 {
218 5 if(!ISP)
219 5 {
220 6 set=1;
221 6 RXSTAT=2;
222 6 START_T0(20);
223 6 }
224 5
225 5 }
226 4 else
227 4 {
228 5 RXSTAT=0;
229 5 CALL_isr_T0();
230 5 }
231 4 }
232 3
233 3 // RXSTAT=0;
234 3 break;
235 3 case 2:
236 3 if(c==ADDR)
237 3 { // LED= !LED;
C51 COMPILER V7.05 MAIN 04/08/2005 13:54:31 PAGE 5
238 4 RXtem[2]=c;
239 4 RXSTAT=3;
240 4 START_T0(20);
241 4 }
242 3 else
243 3 {
244 4 RXSTAT=0;
245 4 CALL_isr_T0();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -