📄 finish.lst
字号:
C51 COMPILER V7.06 FINISH 06/18/2005 14:53:21 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE FINISH
OBJECT MODULE PLACED IN Finish.OBJ
COMPILER INVOKED BY: D:\keil\C51\BIN\C51.EXE Finish.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "HeadFile.h"
2 /**************************************************************************
3 函 数 名:Delay()
4 调用函数:无
5 参 数:time
6 返 回 值:无
7 函数功能:延时
8 ***************************************************************************/
9
10 void Delay(uchar time)
11 {
12 1 while (time--)
13 1 {
14 2 _nop_();
15 2 }
16 1 }
17
18
19 /**************************************************************************
20 函 数 名:SomeNOP()
21 调用函数:无
22 参 数:time
23 返 回 值:无
24 函数功能:延时time个机器周期
25 ***************************************************************************/
26
27 void SomeNOP(uint time)
28 {
29 1 while (time--)
30 1 {
31 2 _nop_();
32 2 }
33 1 }
34
35
36 /**************************************************************************
37 函 数 名:Show()
38 调用函数:无
39 参 数:number, index
40 返 回 值:无
41 函数功能:在指定位置显示一个数字
42 ***************************************************************************/
43
44 void Show(uint number, uchar index)
45 {
46 1 uchar *p_Address[8]; //指针数组保存8个数码管的地址
47 1
48 1 p_Address[0] = HC574_0; //对指针数组的初始化
49 1
50 1 p_Address[1] = HC574_1; //对指针数组的初始化
51 1
52 1 p_Address[2] = HC574_2; //对指针数组的初始化
53 1
54 1 p_Address[3] = HC574_3; //对指针数组的初始化
55 1
C51 COMPILER V7.06 FINISH 06/18/2005 14:53:21 PAGE 2
56 1 p_Address[4] = HC574_4; //对指针数组的初始化
57 1
58 1 p_Address[5] = HC574_5; //对指针数组的初始化
59 1
60 1 p_Address[6] = HC574_6; //对指针数组的初始化
61 1
62 1 p_Address[7] = HC574_7; //对指针数组的初始化
63 1
64 1 if (number == 0)
65 1 {
66 2 *p_Address[index] = NumTab[0];
67 2 }/*end if*/
68 1
69 1 while (number > 0)
70 1 {
71 2 *p_Address[index] = NumTab[number%10];
72 2
73 2 index++;
74 2
75 2 if (index > 7)
76 2 {
77 3 index = 0;
78 3
79 3 *p_Address[index] = NumTab[number%10];
80 3 }/*end if*/
81 2
82 2 number /= 10;
83 2 }/*end while*/
84 1
85 1 }
86
87
88 /**************************************************************************
89 函 数 名:InitialLED()
90 调用函数:无
91 参 数:无
92 返 回 值:无
93 函数功能:将LED全部清零
94 ***************************************************************************/
95
96 void InitialLED(void)
97 {
98 1 uchar i;
99 1
100 1 uchar *p_Address[8];
101 1
102 1 p_Address[0] = HC574_0;
103 1
104 1 p_Address[1] = HC574_1;
105 1
106 1 p_Address[2] = HC574_2;
107 1
108 1 p_Address[3] = HC574_3;
109 1
110 1 p_Address[4] = HC574_4;
111 1
112 1 p_Address[5] = HC574_5;
113 1
114 1 p_Address[6] = HC574_6;
115 1
116 1 p_Address[7] = HC574_7;
117 1
C51 COMPILER V7.06 FINISH 06/18/2005 14:53:21 PAGE 3
118 1 for (i=0; i<8;i++)
119 1 {
120 2 *p_Address[i] = 0xff; //将所有的数码管都清零
121 2 }
122 1 }
123
124
125 /**************************************************************************
126 函 数 名:CheckStatus()
127 调用函数:无
128 参 数:无
129 返 回 值:0或1
130 函数功能:检测小车是否离开缓冲区
131 ***************************************************************************/
132
133 uchar CheckStatus(void)
134 {
135 1 // ET0 = 1; //开定时器1中断
136 1
137 1 if (g_PulseCount==4 | g_PulseCount==10) //到第四个或者是第十个黑线处跳出
138 1 {
139 2 g_Time08sFLAG = 0;
140 2
141 2 if (g_PulseCount == 5)
142 2 {
143 3 g_PulseCount = 4;
144 3 }
145 2
146 2 else if (g_PulseCount == 11)
147 2 {
148 3 g_PulseCount = 10;
149 3 }
150 2
151 2 return 1;
152 2 }
153 1 else if (g_Time08sFLAG > 8) //如果在缓冲区的时间大于8秒也跳出缓冲区
154 1 {
155 2 g_Time08sFLAG = 0;
156 2
157 2 return 1;
158 2 }
159 1 else return 0;
160 1 }
161
162 /**************************************************************************
163 函 数 名:FastForward()
164 调用函数:无
165 参 数:无
166 返 回 值:无
167 函数功能:向前快速前进
168 ***************************************************************************/
169
170 void FastForward(void)
171 {
172 1 p14 = 0;
173 1
174 1 p15 = 1;
175 1 }
176
177 /**************************************************************************
178 函 数 名:FastReverse()
179 调用函数:无
C51 COMPILER V7.06 FINISH 06/18/2005 14:53:21 PAGE 4
180 参 数:无
181 返 回 值:无
182 函数功能:向后快速前进
183 ***************************************************************************/
184
185 void FastReverse(void)
186 {
187 1 p14 = 1;
188 1
189 1 p15 = 0;
190 1 }
191
192
193 /**************************************************************************
194 函 数 名:SlowForward()
195 调用函数:CheckStatus()
196 参 数:无
197 返 回 值:无
198 函数功能:向前慢速前进
199 ***************************************************************************/
200
201 void SlowForward(void)
202 {
203 1 p15 = 1;
204 1
205 1 while (1)
206 1 {
207 2 p14 = ~p14;
208 2
209 2 Delay(50);
210 2
211 2 if (CheckStatus()) //检测状态当满足条件时跳出
212 2 {
213 3 break;
214 3 }
215 2 }
216 1 }
217
218 /**************************************************************************
219 函 数 名:SlowReverse()
220 调用函数:CheckStatus()
221 参 数:无
222 返 回 值:无
223 函数功能:向后慢速前进
224 ***************************************************************************/
225
226 void SlowReverse(void)
227 {
228 1 p14 = 1;
229 1
230 1 while (1)
231 1 {
232 2 p15 = ~p15;
233 2
234 2 Delay(100);
235 2
236 2 if (CheckStatus()) //检测状态当满足条件时跳出
237 2 {
238 3 break;
239 3 }
240 2 }
241 1 }
C51 COMPILER V7.06 FINISH 06/18/2005 14:53:21 PAGE 5
242
243 /**************************************************************************
244 函 数 名:Stop()
245 调用函数:无
246 参 数:无
247 返 回 值:无
248 函数功能:停止前进
249 ***************************************************************************/
250 void Stop(void)
251 {
252 1 p14 = 1;
253 1
254 1 p15 = 1;
255 1 }
256
257
258 /**************************************************************************
259 函 数 名:DetectPort0()
260 调用函数:SomeNOP()
261 参 数:无
262 返 回 值:1或者0
263 函数功能:用来检p10口测脉冲宽度是否达到要求
264 ***************************************************************************/
265
266 uchar DetectPort0(void)
267 {
268 1 uchar i;
269 1
270 1 uchar count = 0; //计数变量用来计算脉冲的宽度是否满足条件
271 1
272 1 for (i=0; i<10; i++)
273 1 {
274 2 if (p10 == 0)
275 2 {
276 3 count++;
277 3
278 3 SomeNOP(200);
279 3 }
280 2 }
281 1
282 1 if (count>4)
283 1 {
284 2 return 1;
285 2 }
286 1 else return 0;
287 1 }
288
289 /**************************************************************************
290 函 数 名:DetectPort1()
291 调用函数:SomeNOP()
292 参 数:无
293 返 回 值:1或者0
294 函数功能:用来检p11口测脉冲宽度是否达到要求
295 ***************************************************************************/
296
297 uchar DetectPort1(void)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -