📄 text1.lst
字号:
C51 COMPILER V7.06 TEXT1 01/01/2008 14:52:07 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN Text1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Text1.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*////////////////////////////////////////
2 可存
3
4 *////////////////////////////////////////////
5 #include <REGX51.H>
*** WARNING C318 IN LINE 5 OF Text1.c: can't open file 'REGX51.H'
6 #include <led1602.h>
*** WARNING C318 IN LINE 6 OF Text1.c: can't open file 'led1602.h'
7
8 unsigned char code table[]={0x3f,0x06,0x5b,0x4f,
9 0x66,0x6d,0x7d,0x07,
10 0x7f,0x6f,0x77,0x7c,
11 0x39,0x5e,0x79,0x71};
12 unsigned char temp,flagplay;
13 unsigned char key=0,clr=0;
14 unsigned char i,j,t=0;
15 unsigned char STH0,replay=0;
16 unsigned char STL0;
17 unsigned int code tab[]={0,0,65110,65058,
18 65030,64968,64898,64820,
19 64777,64684,64580,64524,
20 64400,64260,64103,64021};
21
22 unsigned int tabekey[17]; ////键记忆
23 unsigned int tabetimer[17]; ///时间记忆
24 unsigned int stoptimer[17];
25 unsigned int tcont,toper=0,keycont=0;
26 ////////////////////////////////////////
27 void initTimer(void)
28 {
29 1 TMOD=0x10;
*** ERROR C202 IN LINE 29 OF TEXT1.C: 'TMOD': undefined identifier
30 1 TH0=0xfc;
*** ERROR C202 IN LINE 30 OF TEXT1.C: 'TH0': undefined identifier
31 1 TL0=0x18;
*** ERROR C202 IN LINE 31 OF TEXT1.C: 'TL0': undefined identifier
32 1 }
33
34 /////////////////////////////////////////
35
36
37 void main(void)
38 {
39 1 init();
40 1 delay(200);
41 1 writestring(0,0,"guo xiao chun");
42 1 initTimer();
43 1 ET0=1;
44 1 ET1=1;
45 1 TR0=0;
46 1 EA=1;
47 1 while(1)
48 1 {
49 2 //////////////////////////////////////////////////////////
50 2 P2=0xff;
C51 COMPILER V7.06 TEXT1 01/01/2008 14:52:07 PAGE 2
51 2 P2_4=0;
52 2 temp=P2;
53 2 temp=temp & 0x0f;
54 2 if (temp!=0x0f)
55 2 {
56 3 for(i=50;i>0;i--)
57 3 for(j=200;j>0;j--);
58 3 temp=P2;
59 3 temp=temp & 0x0f;
60 3 if (temp!=0x0f)
61 3 {
62 4 temp=P2;
63 4 temp=temp & 0x0f;
64 4 switch(temp)
65 4 {
66 5 case 0x0e:
67 5 key=0;
68 5 writestring(5,1,"clr ");
69 5 break;
70 5 case 0x0d:
71 5 key=1;
72 5 break;
73 5 case 0x0b:
74 5 key=2;
75 5 writestring(1,1,"si");
76 5 break;
77 5 case 0x07:
78 5 key=3;
79 5 writestring(1,1,"la");
80 5 break;
81 5 }
82 4 temp=P2;
83 4 if(key!=1)
84 4 {
85 5 P0=table[key];
86 5 STH0=tab[key]/256;
87 5 STL0=tab[key]%256;
88 5 TR1=1;
89 5 tabetimer[keycont]=tcont; ///开始按键时间
90 5 tabekey[keycont]=tab[key];
91 5 }
92 4
93 4 temp=temp & 0x0f;
94 4 while(temp!=0x0f)
95 4 {
96 5 temp=P2;
97 5 temp=temp & 0x0f;
98 5 }
99 4
100 4 TR1=0; //////////按键放开音乐停止
101 4
102 4 if(key==0)
103 4 {
104 5 TR1=0;
105 5 tcont=0;
106 5 flagplay=0;
107 5 writestring(5,1," ");
108 5 for(clr=0;clr<15;clr++)
109 5 {
110 6 tabetimer[clr]=0; tabekey[clr]=0; ///清除所存的曲子
111 6 keycont=0;
112 6
C51 COMPILER V7.06 TEXT1 01/01/2008 14:52:07 PAGE 3
113 6 }
114 5 }
115 4 ////////////////////////////
116 4 if(flagplay==0&&key!=1&&key!=0)
117 4 {
118 5 stoptimer[keycont]=tcont; //结束按键时间
119 5 writestring(1,1," ");
120 5 keycont++;
121 5 }
122 4
123 4 if(key==1&&flagplay==1) ////////////开始播放
124 4 {
125 5 writestring(5,1,"play");
126 5 TR0=1;
127 5 //replay=~replay;
128 5 }
129 4 if(key==1&&flagplay!=1) ///////////////////停止记录按键
130 4 {
131 5 TR0=0;
132 5 TR1=0;
133 5 t=0;
134 5 // keycont=0;
135 5 tcont=0;
136 5 flagplay=1; ///用定时器播放音乐
137 5 writestring(5,1,"stop");
138 5 }
139 4
140 4 }
141 3 }
142 2 /////////////////////////////////////////////////////////
143 2 P2=0xff;
144 2 P2_5=0;
145 2 temp=P2;
146 2 temp=temp &0x0f;
147 2 if (temp!=0x0f)
148 2 {
149 3 for(i=50;i>0;i--)
150 3 for(j=200;j>0;j--);
151 3 temp=P2;
152 3 temp=temp & 0x0f;
153 3 if (temp!=0x0f)
154 3 {
155 4 temp=P2;
156 4 temp=temp & 0x0f;
157 4 switch(temp)
158 4 {
159 5 case 0x0e:
160 5 key=4;
161 5 writestring(1,1,"so");
162 5 break;
163 5 case 0x0d:
164 5 key=5;
165 5 writestring(1,1,"fa");
166 5 break;
167 5 case 0x0b:
168 5 key=6;
169 5 writestring(1,1,"me");
170 5 break;
171 5 case 0x07:
172 5 key=7;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -