📄 uart.lst
字号:
C51 COMPILER V8.02 UART 09/08/2008 11:33:28 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE UART
OBJECT MODULE PLACED IN .\twoauto\UART.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE UART.c BROWSE DEBUG OBJECTEXTEND OBJECT(.\twoauto\UART.obj)
line level source
1 #include "REG51.h"
2 #include "lcd.h"
3 #include "key.h"
4 //-----------------------------------
5 extern xdata unsigned char CEedit;
6 extern xdata unsigned char CEspeed;
7 extern xdata unsigned char CEWW;
8 extern xdata unsigned char CEbegin;
9 extern xdata unsigned char CEend;
10 extern xdata unsigned char CEauto;
11 extern xdata unsigned char CEP1D;
12 //extern xdata unsigned char CEFF;
13 //extern xdata unsigned char CEPP_Sign;
14 extern xdata unsigned char CElamp;
15 extern xdata unsigned char CEcut;
16 extern xdata unsigned char DCEFF[];
17 extern xdata unsigned char CDSSUart_En;
18 extern xdata unsigned char LRUart_Sign;
19 extern xdata unsigned char LRCount;
20 extern xdata unsigned char StartEn;
21 extern xdata unsigned char SaveEn;
22 //xdata unsigned char RRBuffer[50][2];
23 ///int OutKey=0;
24 //int LcdST=0;
25 //int LcdData=0;
26 //-------------------------------------------
27
28 unsigned char UARTbme (unsigned char utST)
29 {
30 1 unsigned char fefe;
31 1 long TimeEr,TimeEr1;
32 1 TimeEr1 = 5000;
33 1 do{
34 2
35 2 TimeEr1 --;
36 2 if(TimeEr1 == 0) { return (1); }
37 2
38 2 TI=0;
39 2 SBUF=utST;
40 2 while (!TI);
41 2 RI=0;
42 2 // SSTAT=0x60;
43 2 TimeEr=200000;
44 2 while (!RI)
45 2 { TimeEr--;
46 3 if(TimeEr==0) { return (1); }
47 3 }
48 2 fefe=SBUF;
49 2 RI=0;
50 2 } while(fefe!=utST);
51 1 return (0);
52 1 }
53
54 unsigned char UARTend (unsigned char utST)
55 {
C51 COMPILER V8.02 UART 09/08/2008 11:33:28 PAGE 2
56 1 unsigned char fefe;
57 1 long TimeEr;
58 1 TI=0;
59 1 SBUF=utST;
60 1 while (!TI);
61 1 RI=0;
62 1 TimeEr=200000;
63 1 while (!RI)
64 1 { TimeEr--;
65 2 if(TimeEr==0) { return (1); }
66 2 }
67 1 fefe=SBUF;
68 1 RI=0;
69 1 if(fefe==utST) { return(0); }
70 1 else { return (2); }
71 1 }
72 Sendchar ( unsigned char SendST, unsigned char SendData )
73 {
74 1 unsigned char seed;
75 1 seed= SendData;
76 1 TI=0;
77 1 SBUF=SendST;
78 1 while (!TI);
79 1 TI=0;
80 1 SBUF=seed;
81 1 while (!TI);
82 1 }
83
84 /*
85 UARTRer()
86 {
87 long TimeEr;
88 RI=0;
89 TimeEr=400000;
90 while(!RI)
91 {
92 TimeEr--;
93 if(TimeEr == 0)
94 return (2);
95 }
96 return 1;
97
98
99
100 }
101
102 ReceiveData(unsigned char utST) //receiv the head address if
103 { unsigned char i=0,whexet = 1; //the head addr equal the ask addr the return 0,else return 1
104 unsigned char fefe;
105 long int TimeEr,TimeEr1,TimeEr2;
106 TimeEr1 = 5000;
107 TimeEr2 = 5000;
108 while (fefe!=utST) //receive always while fefe == utSt
109 { TimeEr1--;
110 if(UARTRer()== 1)
111 {
112
113 fefe=SBUF;
114 RI=0;
115 TI=0;
116 SBUF=fefe;
117 while (!TI);
C51 COMPILER V8.02 UART 09/08/2008 11:33:28 PAGE 3
118 }
119 else {return (1);}
120 if(TimeEr1 == 0){return (2);}
121 }
122
123
124 while (fefe==utST) //receive always while fefe != utSt
125 {
126 TimeEr2 -- ;
127 if(TimeEr2 == 0){return (2);}
128
129 if(UARTRer()== 1)
130 {
131 fefe=SBUF;
132 RI=0;
133
134 if(fefe == utST)
135 {
136 TI=0;
137 SBUF=fefe;
138 while (!TI);
139 }
140 else
141 {
142 RRBuffer[0][0]= fefe; //receive the unequal data then give it to rrbuffer!
143 }
144 }
145 else{ return (2); }
146 }
147
148
149 while(whexet == 1)
150 {
151
152 RI=0;
153 TimeEr=400000;
154 while (!RI)
155 {
156 TimeEr--;
157
158 if(TimeEr==0) { return (2); }
159 }
160
161 RRBuffer[i][1]=SBUF;
162 RI=0;
163 TimeEr=400000;
164
165 i++;
166 while (!RI)
167 {
168 TimeEr--;
169
170 if(TimeEr==0) { return (2); }
171 }
172
173 RRBuffer[i][0]=SBUF;
174 RI=0;
175
176 if(RRBuffer[i][0] == 0x79)
177 {
178 whexet = 0;
179 }
C51 COMPILER V8.02 UART 09/08/2008 11:33:28 PAGE 4
180
181 if(i>50)
182 {
183 i = 0;
184 return (2);
185 }
186
187
188 }
189
190
191 TI=0;
192 SBUF=0x79;
193 while (!TI);
194 TI = 0;
195 return(0); //if all if right return 0;
196 }
197
198 void UARTRRBuffer() //send the data of buffer which used for test;
199 {
200 int i = 0,whexet =1;
201 while(whexet == 1)
202 {
203 TI=0;
204 SBUF=i;
205 while (!TI);
206 TI=0;
207 TI=0;
208 SBUF=RRBuffer[i][0];
209 while (!TI);
210 TI=0;
211 SBUF=RRBuffer[i][1];
212 while (!TI);
213 i++;
214 if(RRBuffer[i+1][0]==0x79)
215 {
216 whexet = 0;
217 }
218
219
220
221
222 }
223
224 }
225
226 void DealReceiveData()
227 {
228 unsigned char i = 0,whexet = 1;
229 while(whexet == 1)
230 {
231
232 if(RRBuffer[i][0]==0xC0){Data_H = RRBuffer[i][1]*100;}
233 if(RRBuffer[i][0]==0xC1){Data_PSL = RRBuffer[i][1];}
234 if(RRBuffer[i][0]==0xC5){Data_S = RRBuffer[i][1]*100;}
235 if(RRBuffer[i][0]==0xC1){Data_SLS = RRBuffer[i][1];}
236 if(RRBuffer[i][0]==0xC8){Data_DIR = RRBuffer[i][1];}
237 if(RRBuffer[i][0]==0xCb){Data_T = RRBuffer[i][1]*50;}
238 if(RRBuffer[i][0]==0xe1){Data_FO = RRBuffer[i][1]*100;}
239 if(RRBuffer[i][0]==0xe2){Data_FC = RRBuffer[i][1];}
240 if(RRBuffer[i][0]==0xe4){Data_SFM = RRBuffer[i][1];}
241 if(RRBuffer[i][0]==0xe6){Data_ANU = RRBuffer[i][1];}
C51 COMPILER V8.02 UART 09/08/2008 11:33:28 PAGE 5
242 if(RRBuffer[i][0]==0xF5){Data_D1 = RRBuffer[i][1];}
243 if(RRBuffer[i][0]==0xF6){Data_D2 = RRBuffer[i][1];}
244 if(RRBuffer[i][0]==0xF7){Data_D3 = RRBuffer[i][1]*100;}
245 if(RRBuffer[i][0]==0xF8){Data_W1 = RRBuffer[i][1]*100;}
246 if(RRBuffer[i][0]==0xF9){Data_W2 = RRBuffer[i][1]*100;}
247
248 i++;
249 if(RRBuffer[i][0]==0x79)
250 {
251 whexet = 0;
252 }
253
254 }
255
256 } */
257 /*
258 void UARTrr(void)
259 {
260 unsigned char ER;
261 ER = ReceiveData(0x70);
262 if(ER == 0)
263 {
264 DealReceiveData();
265 }
266 if(ER == 1)
267 {while(1)
268 {
269 DispER(ER);
270 }
271 }
272 if(ER == 2)
273 {
274 while(1)
275 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -