📄 text1.lst
字号:
C51 COMPILER V6.23a TEXT1 05/17/2007 10:35:00 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE Text1.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include"reg51.h"
2 #include"INTRINS.H"
3 //#include"math.h"
4 #define uchar unsigned char
5 #define uint unsigned int
6
7
8 sbit SW=P3^7;
9 sbit speed1=P1^5;
10 sbit speed2=P1^4;
11 sbit insert=P1^6;
12 sbit conti=P1^7;
13 sbit led=P1^3;
14
15 sbit L1=P1^0;
16 sbit L2=P1^1;
17 sbit L3=P1^2;
18
19 sbit wdi=P3^5;
20
21 uchar time_se;
22 uint time_mse;
23 bit led_c;
24
25 void watch_dog();
26 void delay(uint number);
27 one_cycle(uchar speed);
28
29
30 void delay(uint number)
31 {
32 1 while(number--)
33 1 { // watch_dog();wdi=0;
34 2
35 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
36 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
37 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
38 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();wdi=1;
39 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
40 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
41 2 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
42 2 wdi=0;
43 2 }
44 1
45 1
46 1
47 1 }
48
49
50
51 void one_cy(uchar speed) //单位 km/h
52 {
53 1 uint speed_3;
54 1 uint speed_2;
55 1 speed_2=(2*3600)/speed;
C51 COMPILER V6.23a TEXT1 05/17/2007 10:35:00 PAGE 2
56 1 speed_3=(3*3600)/speed;
57 1 TR0=0;
58 1 TH0=0XFc;
59 1 TL0=0X18;
60 1
61 1 TR0=1;
62 1 EA=1;
63 1 L1=0;
64 1
65 1 time_mse=0;
66 1 time_se=0;
67 1 if(insert==1)
68 1 while(((time_se*1000)+time_mse)<(speed_2+speed_3))watch_dog();
69 1 else
70 1 { while(((time_se*1000)+time_mse)<(speed_3))watch_dog();
71 2 L1=1;
72 2 while(((time_se*1000)+time_mse)<(speed_2+speed_3))watch_dog();
73 2 L1=0;
74 2 }
75 1 L2=0;
76 1 while(((time_se*1000)+time_mse)<(speed_2+(2*speed_3)))watch_dog();
77 1 L1=1;
78 1 if(insert==0) L2=1;
79 1 while(((time_se*1000)+time_mse)<((2*speed_2)+(2*speed_3)))watch_dog();
80 1 L3=0;
81 1 if(insert==0) L2=0;
82 1 while(((time_se*1000)+time_mse)<((2*speed_2)+(3*speed_3)))watch_dog();
83 1 L2=1;
84 1 if(insert==0) L3=1;
85 1 if(insert==1)
86 1 while(((time_se*1000)+time_mse)<((3*speed_2)+(4*speed_3)))watch_dog();
87 1 else
88 1 {while(((time_se*1000)+time_mse)<((3*speed_2)+(3*speed_3)))watch_dog();
89 2 L3=0;
90 2 while(((time_se*1000)+time_mse)<((3*speed_2)+(4*speed_3)))watch_dog();
91 2 }
92 1
93 1 L3=1;
94 1
95 1
96 1 }
97
98
99
100
101
102
103
104
105 void watch_dog()
106 {
107 1 wdi=0;
108 1 wdi=1;
109 1 delay(5);
110 1 wdi=0;
111 1
112 1 }
113
114 main()
115 {
116 1 uchar speed=0;
117 1 uchar m_c=0;
C51 COMPILER V6.23a TEXT1 05/17/2007 10:35:00 PAGE 3
118 1
119 1 L1=1;
120 1 L2=1;
121 1 L3=1;
122 1
123 1 led_c=0;
124 1
125 1 time_se=0;
126 1 time_mse=0;
127 1
128 1 led=0;
129 1 delay(2000);
130 1 led=1;
131 1
132 1
133 1 TMOD=0X01;
134 1 TH0=0XFc;
135 1 TL0=0X18;
136 1
137 1 ET0=1;
138 1 ET1=0;
139 1 TR0=1;
140 1 EA=1;
141 1
142 1
143 1
144 1
145 1 while(1)
146 1 {
147 2 watch_dog();
148 2 if(speed1==0) speed|=0x01;
149 2 if(speed2==0) speed|=0x02;
150 2 if((conti==1)&&(SW==0)) //不连续发
151 2 {switch(speed)
152 3 {case 0:one_cy(30); //30km/h
153 4 break;
154 4 case 1:one_cy(60); //60km/h
155 4 break;
156 4 case 2:one_cy(120); //120km/h
157 4 break;
158 4 case 3:one_cy(150); //150km/h
159 4 break;
160 4 default:break;
161 4 }
162 3 }
163 2 if(conti==0)
164 2 {
165 3 if(SW==0)
166 3 { delay(1000);
167 4 while(1)
168 4 {
169 5
170 5 for(m_c=0;m_c<3;m_c++)
171 5 {
172 6 one_cy(100);
173 6
174 6 TR0=0;
175 6 TH0=0XFc;
176 6 TL0=0X18;
177 6 TR0=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -