⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text1.lst

📁 本文件是用51单片机设计电子琴的资料文件
💻 LST
📖 第 1 页 / 共 2 页
字号:
 173   5                                        writestring(1,1,"re");  
 174   5                          break;
C51 COMPILER V7.06   TEXT1                                                                 01/01/2008 14:52:07 PAGE 4   

 175   5                      }
 176   4                                      temp=P2;
 177   4                    P0=table[key];
 178   4                    STH0=tab[key]/256;
 179   4                    STL0=tab[key]%256;
 180   4                                tabetimer[keycont]=tcont; ///开始按键时间
 181   4                    TR1=1;
 182   4                    temp=temp & 0x0f;              
 183   4                    while(temp!=0x0f)
 184   4                      {
 185   5                        temp=P2;
 186   5                        temp=temp & 0x0f;              
 187   5                      }
 188   4                    TR1=0; writestring(1,1,"  ");
 189   4                                tabekey[keycont]=tab[key];
 190   4                                stoptimer[keycont]=tcont;     //结束按键时间
 191   4                                 keycont++;
 192   4                            
 193   4                  }
 194   3              }
 195   2      ///////////////////////////////////////////////////////
 196   2            P2=0xff;
 197   2            P2_6=0;
 198   2            temp=P2;
 199   2            temp=temp & 0x0f;
 200   2            if (temp!=0x0f)
 201   2              {
 202   3                for(i=50;i>0;i--)
 203   3                for(j=200;j>0;j--);
 204   3                temp=P2;
 205   3                temp=temp & 0x0f;
 206   3                if (temp!=0x0f)
 207   3                  {
 208   4                    temp=P2;
 209   4                    temp=temp & 0x0f;              
 210   4                    switch(temp)
 211   4                      {
 212   5                        case 0x0e:
 213   5                          key=8;
 214   5                         writestring(1,1,"do"); 
 215   5                          break;
 216   5                        case 0x0d:
 217   5                          key=9;
 218   5                        writestring(1,1,"si");  
 219   5                          break;
 220   5                        case 0x0b:
 221   5                          key=10;
 222   5                        writestring(1,1,"la");  
 223   5                          break;
 224   5                        case 0x07:
 225   5                          key=11;
 226   5                        writestring(1,1,"so");   
 227   5                          break;
 228   5                      }
 229   4                    temp=P2;
 230   4                    P0=table[key];
 231   4                                tabekey[keycont]=tab[key];
 232   4                    STH0=tab[key]/256;
 233   4                    STL0=tab[key]%256;
 234   4                    TR1=1;
 235   4                                tabetimer[keycont]=tcont; ///开始按键时间
 236   4                    temp=temp & 0x0f;              
C51 COMPILER V7.06   TEXT1                                                                 01/01/2008 14:52:07 PAGE 5   

 237   4                    while(temp!=0x0f)
 238   4                      {
 239   5                        temp=P2;
 240   5                        temp=temp & 0x0f;              
 241   5                      }
 242   4                    TR1=0; writestring(1,1,"  ");
 243   4                                stoptimer[keycont]=tcont;     //结束按键时间
 244   4                                keycont++;
 245   4                  }
 246   3              }
 247   2      
 248   2            P2=0xff;
 249   2            P2_7=0;
 250   2            temp=P2;
 251   2            temp=temp & 0x0f;
 252   2            if (temp!=0x0f)
 253   2              {
 254   3                for(i=50;i>0;i--)
 255   3                for(j=200;j>0;j--);
 256   3                temp=P2;
 257   3                temp=temp & 0x0f;
 258   3                if (temp!=0x0f)
 259   3                  {
 260   4                    temp=P2;
 261   4                    temp=temp & 0x0f;              
 262   4                    switch(temp)
 263   4                      {
 264   5                        case 0x0e:
 265   5                          key=12;
 266   5                         writestring(1,1,"fa"); 
 267   5                          break;
 268   5                        case 0x0d:
 269   5                          key=13;
 270   5                         writestring(1,1,"me"); 
 271   5                          break;
 272   5                        case 0x0b:
 273   5                          key=14;
 274   5                         writestring(1,1,"re"); 
 275   5                          break;
 276   5                        case 0x07:
 277   5                          key=15;
 278   5                         writestring(1,1,"do");  
 279   5                          break;
 280   5                      }
 281   4                    temp=P2;
 282   4                    P1_0=~P1_0;
 283   4                    P0=table[key];
 284   4                                tabekey[keycont]=tab[key];
 285   4                    STH0=tab[key]/256;
 286   4                    STL0=tab[key]%256;
 287   4                                tabetimer[keycont]=tcont; ///开始按键时间
 288   4                    TR1=1;
 289   4                    temp=temp & 0x0f;              
 290   4                    while(temp!=0x0f)
 291   4                      {
 292   5                        temp=P2;
 293   5                        temp=temp & 0x0f;              
 294   5                      }
 295   4                    TR1=0; writestring(1,1,"  ");
 296   4                                stoptimer[keycont]=tcont;     //结束按键时间
 297   4                                keycont++;
 298   4                  
C51 COMPILER V7.06   TEXT1                                                                 01/01/2008 14:52:07 PAGE 6   

 299   4                 }       
 300   3             }
 301   2              }
 302   1      }
 303          
 304          //////////////////////////////////////////////////
 305          void  timer0(void) interrupt 1
 306          {
 307   1        TH0=0xfc;
 308   1        TL0=0x18;   
 309   1         toper++;
 310   1          
 311   1          if(toper==5) 
 312   1                {
 313   2                  toper=0; P3_7=~P3_7;        
 314   2                      tcont++;
 315   2                        if(tcont==65535)
 316   2                         { 
 317   3                               writestring(5,1,"full");
 318   3                          
 319   3                              }
 320   2                 }
 321   1              if(flagplay==1)
 322   1             {
 323   2                   if(tcont==tabetimer[t])    //用来判断播放时间是否到了前面的按键时间
 324   2                     //for(t=0;t<=keycont;t++)
 325   2                          { 
 326   3                             STH0=tabekey[t]/256;
 327   3                     STL0=tabekey[t]%256; 
 328   3                                 TR1=1;
 329   3                                 //delay(255);
 330   3                                                         
 331   3                                 ///TR1=0;                               
 332   3                               }
 333   2                  if(tcont==stoptimer[t]) 
 334   2                        {
 335   3                            t++;  TR1=0;         ///第t个按键时间到
 336   3                                if(t==keycont)
 337   3                                 {  
 338   4                                  t=0;            ////////播放完毕等待下次按键播放
 339   4                                   tcont=0; TR0=0;      
 340   4                                 }
 341   3                         }
 342   2            }
 343   1      }
 344          
 345          /////////////////////////////////////////////////
 346          void timer1(void) interrupt 3
 347          {
 348   1        TH1=STH0;
 349   1        TL1=STL0;
 350   1        P3_4=~P3_4;
 351   1        TR0=1;       ///当有键按下的时候定时器一开始记按键时间
 352   1      }

C51 COMPILATION COMPLETE.  2 WARNING(S),  3 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -