?? liwan.lst
字號(hào):
C51 COMPILER V6.12 LIWAN 08/24/2007 16:40:41 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE LIWAN
OBJECT MODULE PLACED IN .\LiWan.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE .\LiWan.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <REG52.H>
2 #include "SoundPlay.h"
3
4 unsigned char RunMode;
5
6 //**********************************System Fuction*************************************************
7 void Delay1ms(unsigned int count)
8 {
9 1 unsigned int i,j;
10 1 for(i=0;i<count;i++)
11 1 for(j=0;j<120;j++);
12 1 }
13
14 unsigned char code LEDDisplayCode[] = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8, //0~7
15 0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0xFF};
16
17 void Display(unsigned char Value)
18 {
19 1 P3 = LEDDisplayCode[Value];
20 1 }
21
22 void LEDFlash(unsigned char Count)
23 {
24 1 unsigned char i;
25 1 bit Flag;
26 1 for(i = 0; i<Count;i++)
27 1 {
28 2 Flag = !Flag;
29 2 if(Flag)
30 2 Display(RunMode);
31 2 else
32 2 Display(0x10);
33 2 Delay1ms(100);
34 2 }
35 1 Display(RunMode);
36 1 }
37
38 unsigned char GetKey(void)
39 {
40 1 unsigned char KeyTemp,CheckValue,Key = 0x00;
41 1 CheckValue = P2&0x32;
42 1 if(CheckValue==0x32)
43 1 return 0x00;
44 1
45 1 Delay1ms(10);
46 1 KeyTemp = P2&0x32;
47 1 if(KeyTemp==CheckValue)
48 1 return 0x00;
49 1
50 1 if(!(CheckValue&0x02))
51 1 Key|=0x01;
52 1 if(!(CheckValue&0x10))
53 1 Key|=0x02;
54 1 if(!(CheckValue&0x20))
55 1 Key|=0x04;
C51 COMPILER V6.12 LIWAN 08/24/2007 16:40:41 PAGE 2
56 1 return Key;
57 1 }
58
59 unsigned int Timer0Count,SystemSpeed,SystemSpeedIndex;
60 void InitialTimer2(void)
61 {
62 1 T2CON = 0x00; //16 Bit Auto-Reload Mode
63 1 TH2 = RCAP2H = 0xFC; //重裝值,初始值 TL2 = RCAP2L = 0x18;
64 1 ET2=1; //定時(shí)器 2 中斷允許
65 1 TR2 = 1; //定時(shí)器 2 啟動(dòng)
66 1 EA=1;
67 1 }
68
69 unsigned int code SpeedCode[]={ 1, 2, 3, 5, 8, 10, 14, 17, 20, 30,
70 40, 50, 60, 70, 80, 90, 100, 120, 140, 160,
71 180, 200, 300, 400, 500, 600, 700, 800, 900,1000};//30
72 void SetSpeed(unsigned char Speed)
73 {
74 1 SystemSpeed =SpeedCode[Speed];
75 1 }
76
77 void LEDShow(unsigned int LEDStatus)
78 {
79 1 P1 = ~(LEDStatus&0x00FF);
80 1 P0 = ~((LEDStatus>>8)&0x00FF);
81 1 }
82
83 void InitialCPU(void)
84 {
85 1 RunMode = 0x00;
86 1 Timer0Count = 0;
87 1 SystemSpeedIndex = 9;
88 1
89 1 P1 = 0x00;
90 1 P0 = 0x00;
91 1 P2 = 0xFF;
92 1 P3 = 0x00;
93 1 Delay1ms(500);
94 1 P1 = 0xFF;
95 1 P0 = 0xFF;
96 1 P2 = 0xFF;
97 1 P3 = 0xFF;
98 1 SetSpeed(SystemSpeedIndex);
99 1 Display(RunMode);
100 1 }
101
102 //Mode 0
103 unsigned int LEDIndex = 0;
104 bit LEDDirection = 1,LEDFlag = 1;
105 void Mode_0(void)
106 {
107 1 LEDShow(0x0001<<LEDIndex);
108 1 LEDIndex = (LEDIndex+1)%16;
109 1 }
110 //Mode 1
111 void Mode_1(void)
112 {
113 1 LEDShow(0x8000>>LEDIndex);
114 1 LEDIndex = (LEDIndex+1)%16;
115 1 }
116 //Mode 2
117 void Mode_2(void)
C51 COMPILER V6.12 LIWAN 08/24/2007 16:40:41 PAGE 3
118 {
119 1 if(LEDDirection)
120 1 LEDShow(0x0001<<LEDIndex);
121 1 else
122 1 LEDShow(0x8000>>LEDIndex);
123 1 if(LEDIndex==15)
124 1 LEDDirection = !LEDDirection;
125 1 LEDIndex = (LEDIndex+1)%16;
126 1 }
127 //Mode 3
128 void Mode_3(void)
129 {
130 1 if(LEDDirection)
131 1 LEDShow(~(0x0001<<LEDIndex));
132 1 else
133 1 LEDShow(~(0x8000>>LEDIndex));
134 1 if(LEDIndex==15)
135 1 LEDDirection = !LEDDirection;
136 1 LEDIndex = (LEDIndex+1)%16;
137 1 }
138
139 //Mode 4
140 void Mode_4(void)
141 {
142 1 if(LEDDirection)
143 1 {
144 2 if(LEDFlag)
145 2 LEDShow(0xFFFE<<LEDIndex);
146 2 else
147 2 LEDShow(~(0x7FFF>>LEDIndex));
148 2 }
149 1 else
150 1 {
151 2 if(LEDFlag)
152 2 LEDShow(0x7FFF>>LEDIndex);
153 2 else
154 2 LEDShow(~(0xFFFE<<LEDIndex));
155 2 }
156 1 if(LEDIndex==15)
157 1 {
158 2 LEDDirection = !LEDDirection;
159 2 if(LEDDirection) LEDFlag = !LEDFlag;
160 2 }
161 1 LEDIndex = (LEDIndex+1)%16;
162 1 }
163
164 //Mode 5
165 void Mode_5(void)
166 {
167 1 if(LEDDirection)
168 1 LEDShow(0x000F<<LEDIndex);
169 1 else
170 1 LEDShow(0xF000>>LEDIndex);
171 1 if(LEDIndex==15)
172 1 LEDDirection = !LEDDirection;
173 1 LEDIndex = (LEDIndex+1)%16;
174 1 }
175
176 //Mode 6
177 void Mode_6(void)
178 {
179 1 if(LEDDirection)
C51 COMPILER V6.12 LIWAN 08/24/2007 16:40:41 PAGE 4
180 1 LEDShow(~(0x000F<<LEDIndex));
181 1 else
182 1 LEDShow(~(0xF000>>LEDIndex));
183 1 if(LEDIndex==15)
184 1 LEDDirection = !LEDDirection;
185 1 LEDIndex = (LEDIndex+1)%16;
186 1 }
187
188 //Mode 7
189 void Mode_7(void)
190 {
191 1 if(LEDDirection)
192 1 LEDShow(0x003F<<LEDIndex);
193 1 else
194 1 LEDShow(0xFC00>>LEDIndex);
195 1 if(LEDIndex==9)
196 1 LEDDirection = !LEDDirection;
197 1 LEDIndex = (LEDIndex+1)%10;
198 1 }
199
200 //Mode 8
201 void Mode_8(void)
202 {
203 1 LEDShow(++LEDIndex);
204 1 }
205
206 void Timer0EventRun(void)
207 {
208 1 if(RunMode==0x00)
209 1 {
210 2 Mode_0();
211 2 }
212 1 else if(RunMode ==0x01)
213 1 {
214 2 Mode_1();
215 2 }
216 1 else if(RunMode ==0x02)
217 1 {
218 2 Mode_2();
219 2 }
220 1 else if(RunMode ==0x03)
221 1 {
222 2 Mode_3();
223 2 }
224 1 else if(RunMode ==0x04)
225 1 {
226 2 Mode_4();
227 2 }
228 1 else if(RunMode ==0x05)
229 1 {
230 2 Mode_5();
231 2 }
232 1 else if(RunMode ==0x06)
233 1 {
234 2 Mode_6();
235 2 }
236 1 else if(RunMode ==0x07)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -