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

📄 my couse.lst

📁 keilc51写的
💻 LST
字号:
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE MY_COUSE
OBJECT MODULE PLACED IN my couse.OBJ
COMPILER INVOKED BY: E:\MCU\Keil\C51\BIN\C51.EXE my couse.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #include <reg52.h>
   2          #define uchar unsigned char
   3          #define uint unsigned int
   4          sbit k1=P2^4;           
   5          sbit k2=P2^5;
   6          sbit k3=P2^6;
   7          sbit k4=P2^7;           //switching port
   8          sbit sk=P3^7;           //speaker port
   9          
  10          uchar tb0[]={           //led bit table /*0,1,2,3,4,5,6,7,8,9,A,b,C,d,E,F,*/
  11          0xA0,0xBE,0x64,0x2C,0x3A,0x29,0x21,0xBC,0x20,0x28,0x30,0x23,0xE1,0x26,0x61,0x71,
  12          };
  13          
  14          unsigned char code music[]={0x31,0x41,0x5d,0x30,0x20,0x1d,0x30,0x40,0x59,0x81,0x51,0x30,0x4e,
  15          0x30,0x40,0x58,0x11,0x82,0x70,0x6d,0x30,0x40,0x59,0x41,0x31,0x20,0x1e,0x30,0x40,0x51,0x00,0x51,
  16          0x50,0x00,0x50,0x60,0x50,0x41,0x01,0x30,0x40,0x51,0x00,0x51,0x30,0x20,0x01,0x30,0x20,0x10,0x10,
  17          0x10,0x80,0x83,0x70,0x80,0x70,0x50,0x03,0x60,0x50,0x40,0x44,0x50,0x60,0x57,0x81,0x83,0x60,0x30,
  18          0x50,0x60,0x55,0x61,0x61,0x50,0x11,0x20,0x35,0x21,0x12,0x10,0x10,0x21,0x30,0x31,0x23,0x21,0x91,
  19          0x91,0x71,0x63,0x55,0x03,0x01,0x30,0x40,0x51,0x51,0x50,0x51,0x50,0x60,0x51,0x41,0x01,0x30,0x40,
  20          0x51,0x51,0x30,0x20,0x11,0x23,0x01,0x30,0x20,0x10,0x11,0x10,0x10,0x81,0x81,0x70,0x71,0x80,0x71,
  21          0x51,0x60,0x50,0x40,0x42,0x50,0x60,0x57,0x81,0x83,0x60,0x30,50,0x60,0x55,0x61,0x61,0x50,0x11,
  22          0x20,0x35,0x21,0x12,0x10,0x10,0x21,0x30,0x31,0x23,0x61,0x52,0x30,0x20,0x0c0,0x30,0x20,0x17,0x80,
  23          0x50,0x60,0x80,0x70,0x80,0x50,0x70,0x60,0x60,0x60,0x70,0x81,0x61,0x70,0x70,0x80,0x70,0x60,0x51,
  24          0x50,0x10,0x20,0x33,0x31,0x70,0x70,0x70,0x31,0x30,0x91,0x91,0x81,0x73,0x6d,0x60,0x60,0x60,0x60,
  25          0x71,0x61,0x70,0x71,0x80,0x91,0x70,0x70,0x0a5,0x91,0x85,0x71,0x61,0x61,0x60,0x62,0x51,0x51,0x20,
  26          0x32,0x01b,0x01,0x30,0x40,0x51,0x51,0x50,0x51,0x50,0x60,0x50,0x41,0x01,0x30,0x40,0x51,0x51,0x30,
  27          0x20,0x11,0x23,0x01,0x30,0x20,0x11,0x11,0x81,0x81,0x70,0x71,0x70,0x80,0x71,0x51,0x51,0x51,0x50,
  28          0x51,0x50,0x60,0x50,0x60,0x51,0x41,0x01,0x30,0x40,0x51,0x51,0x30,0x20,0x11,0x23,0x01,0x30,0x20,
  29          0x11,0x11,0x81,0x81,0x70,0x71,0x80,0x71,0x51,0x60,0x50,0x40,0x42,0x50,0x60,0x55,0x80,0x81,0x60,
  30          0x30,0x50,0x60,0x55,0x61,0x61,0x50,0x11,0x20,0x35,0x21,0x12,0x10,0x10,0x21,0x30,0x31,0x23,0x61,
  31          0x52,0x30,0x20,0x0c0,0x30,0x20,0x17,0x80,0x50,0x60,0x80,0x70,0x80,0x50,0x70,0x60,0x60,0x60,0x70,
  32          0x81,0x61,0x70,0x70,0x70,0x80,0x91,0x71,0x80,0x70,0x60,0x51,0x10,0x20,0x37,0x31,0x70,0x72,0x31,
  33          0x30,0x91,0x91,0x81,0x73,0x6c,0x60,0x60,0x60,0x70,0x81,0x61,0x70,0x71,0x80,0x91,0x70,0x70,0x0a5,
  34          0x91,0x85,0x81,0x81,0x81,0x80,0x82,0x91,0x92,0x91,0x0a0,0x91,0x81,0x8b,0x85,0x70,0x60,0x73,0x51,
  35          0x30,0x40,0x51,0x51,0x50,0x51,0x50,0x60,0x51,0x41,0x01,0x30,0x40,0x51,0x51,0x30,0x20,0x11,0x23,
  36          0x01,0x30,0x20,0x10,0x11,0x10,0x10,0x81,0x81,0x70,0x71,0x80,0x71,0x51,0x60,0x50,0x40,0x42,0x50,
  37          0x60,0x57,0x81,0x83,0x60,0x30,50,0x60,0x55,0x61,0x61,0x50,0x11,0x20,0x35,0x21,0x12,0x10,0x10,
  38          0x21,0x30,0x31,0x23,0x61,0x52,0x30,0x20,0x0c0,0x30,0x20,0x17,0x80,0x50,0x60,0x80,0x70,0x80,0x50,
  39          0x70,0x60,0x60,0x60,0x70,0x81,0x61,0x70,0x70,0x80,0x70,0x60,0x51,0x50,0x10,0x20,0x33,0x31,0x70,
  40          0x70,0x70,0x31,0x30,0x91,0x91,0x81,0x73,0x6d,0x60,0x60,0x60,0x60,0x71,0x61,0x70,0x71,0x80,0x91,
  41          0x70,0x70,0x0a5,0x91,0x85,0x71,0x61,0x61,0x60,0x62,0x51,0x51,0x20,0x32,0x1f,0x60,0x60,0x60,0x70,
  42          0x81,0x61,0x70,0x70,0x70,0x80,0x91,0x71,0x80,0x70,0x60,0x51,0x50,0x10,0x20,0x37,0x31,0x70,0x71,
  43          0x31,0x30,0x91,0x91,0x81,0x73,0x6d,0x60,0x60,0x60,0x70,81,0x61,0x70,0x71,0x70,0x91,0x70,0x70,
  44          0x0a5,0x91,0x85,0x71,0x61,0x61,0x60,0x62,0x51,0x51,0x20,0x32,0x1f,0x00f,0x00f,0x00f,0xff};
  45          
  46          unsigned int code f[]={0000,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,
  47          64260,64400,64524};
  48          
  49          uchar tb1[]={           //led line table
  50          0xfe,0xfd,0xfb,0xf7};
  51          
  52          uchar bc;       //dis couter
  53          uchar buf[4]; //display buffer
  54          uchar ds[2];    //display buffer 2
  55          uchar pds;              //display counter
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 2   

  56          bit ppd;                //display next frame
  57          
  58          uchar ms;               //10ms counter
  59          uchar hs;               //200ms counter
  60          uchar sec;              //1S counter
  61          bit   minb;             //1 min signed
  62          uchar min;
  63          uchar hou;              //hour coner
  64          uchar day;              //day
  65          uchar dat;              //dat
  66          uchar mon;
  67          uchar year;
  68                  
  69          uchar pr;               //music timer regiter
  70          uchar pt;               //music timer couter
  71          uint mc;                //music table couter;
  72          bit mk;                 //music switching,when mk=1:play music, and mk=0:stop;
  73          
  74          bit kp;                 //some key is press
  75          uchar kc;               //receive a effective key velue from remote key*/
  76          
  77          void s_ini(void)
  78          {bc=0;
  79   1       ms=0;
  80   1       hs=20;
  81   1       sec=0;
  82   1       minb=0;
  83   1       hou=0;
  84   1       dat=0;
  85   1       day=0;
  86   1       mon=1;
  87   1       year=6;
  88   1       pr=0;
  89   1       pt=0;
  90   1       mc=0;
  91   1       mk=1;          //enable play music
  92   1       kc=0xff;
  93   1       ppd=0;
  94   1       pds=0xfe;
  95   1       kp=0;
  96   1       P0=0xff;
  97   1       P1=0xff;
  98   1       P2=0xff;
  99   1       P3=0xff;
 100   1       IP=0x20;               //timer 2 interrup as priority
 101   1       IE=0xb2;               //enabled interrup of timer0,time2 &serial port
 102   1       SCON=0x50;
 103   1       TMOD=0x21;
 104   1       TH0=0xF7;              //timer 2.5MS
 105   1       TH1=0xFD;              //baund rate =9600bps
 106   1       TL1=0xFD;
 107   1       TR1=1;
 108   1       TR0=1;
 109   1      }
 110          
 111          void dis(void)  //displqy funtion
 112          {uchar i,j;
 113   1       if(ppd==1)
 114   1         {ppd=0;
 115   2          pds*=2;
 116   2          pds+=1;
 117   2              if(pds==0xff)
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 3   

 118   2                pds=0xfe;
 119   2              P1=pds;
 120   2              }
 121   1       for(i=0;i<2;i++)
 122   1        {j=ds[i]%10;
 123   2         buf[2*i]=tb0[j];
 124   2         j=ds[i]/10;
 125   2         buf[2*i+1]=tb0[j];
 126   2           }
 127   1         
 128   1       }
 129             
 130           
 131          void time(void)
 132          {if(minb==1)
 133   1       {minb=0;
 134   2        min++;
 135   2        if(min==60)
 136   2          {min=0;
 137   3               hou++;
 138   3               if(hou==24)
 139   3                 {hou=0;
 140   4                  dat++;
 141   4                      day++;
 142   4                      }
 143   3              }
 144   2        }
 145   1      }
 146          
 147          void sound(void)                //sound fution
 148          {uchar tt;
 149   1       uchar t1,t2;
 150   1       if(mk==1)                      //play music
 151   1        {if(pt>=pr)           //play next tempi
 152   2         { tt=music[mc];      //fetch the music 
 153   3           mc++;
 154   3          if(tt==0xff)                // the end of music
 155   3                 { mc=0;
 156   4                   sk=1;
 157   4                       TR2=0;
 158   4                      }
 159   3              else 
 160   3               {t1=tt/16;
 161   4                t2=tt%16;                     //separate the frequence& tempi
 162   4                if(t1==0)                     //silence tempi
 163   4                  sk=1,TR2=0;
 164   4                else 
 165   4                 {TH2=RCAP2H=f[t1]/256;
 166   5                      TL2=RCAP2L=f[t1]%256;
 167   5                      TR2=1;
 168   5                 }
 169   4                pr=t2+1;
 170   4                pt=0;
 171   4               }
 172   3        }
 173   2       }
 174   1       else           //stop play music
 175   1        { TR2=0;
 176   2          mc=0;
 177   2          sk=1;
 178   2         }
 179   1      }
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 4   

 180          
 181          void delay(uint t)              //delay t ms
 182          {uchar a;
 183   1       while(t--)
 184   1         {for(a=0;a<150;a++)
 185   2          ;
 186   2        }
 187   1      }
 188          
 189          uchar key(void)
 190          {uchar kv;
 191   1       kv=0xff;
 192   1       if(kp==1)              //some key is press
 193   1        {if(k1==1&&k2==1&&k3==1&&k4==1)
 194   2           {delay(10);
 195   3                if(k1==1&&k2==1&&k3==1&&k4==1)
 196   3                kp=0;
 197   3                }
 198   2              }
 199   1       else if(kp==0)
 200   1         {if(k1==0)
 201   2           {delay(10);
 202   3                if(k1==0)
 203   3                  kv=1,kp=1;
 204   3                }
 205   2               if(k2==0)
 206   2                {delay(10);
 207   3                  if(k2==0)
 208   3                        kv=2,kp=1;
 209   3                 }
 210   2              if(k3==0)
 211   2                {delay(10);
 212   3                  if(k3==0)
 213   3                        kv=3,kp=1;
 214   3                }
 215   2         if(k4==0)
 216   2           {delay(10);
 217   3                if(k4==0)
 218   3                  kv=4,kp=1;
 219   3         }
 220   2        }
 221   1        if(kc!=0xff)
 222   1          {kv=kc;
 223   2               kc=0xff;
 224   2              }
 225   1        return(kv);
 226   1      }
 227          
 228          
 229          
 230            
 231          
 232          main()
 233          { uchar p;
 234   1        s_ini();
 235   1        while(1)
 236   1         {time();
 237   2          ds[0]=sec;
 238   2              ds[1]=min;
 239   2              dis();
 240   2              sound();
 241   2              p=key();
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 5   

 242   2              if(p==1)
 243   2                mk=~mk;
 244   2              else if(p==2)
 245   2                {sec++;
 246   3                 if(sec>=60)
 247   3                   sec=0;
 248   3                 }
 249   2              else if(p==3)
 250   2                {min++;
 251   3                 if(min>=60)
 252   3                   min=0;
 253   3                 }
 254   2              else if(p==4)
 255   2                {sec=0;
 256   3                 min=0;
 257   3                }
 258   2         }
 259   1        
 260   1      }
 261          
 262          void timer0(void) interrupt 1           //time0 over interrupt service
 263          {TH0=0xf7;      //reloard 
 264   1       P0=0xff;
 265   1       P2|=0x0f;
 266   1       P2&=tb1[bc];
 267   1       buf[2]&=~0x20;
 268   1       P0=buf[bc];
 269   1       bc++;
 270   1       if(bc>3)                       //10ms
 271   1         {bc=0;
 272   2          ms++;
 273   2          if(ms==100)
 274   2                {ms=0;
 275   3                 sec++;
 276   3                 if(sec==60)
 277   3                   {sec=0;
 278   4                        minb=1;
 279   4                       }
 280   3                 }
 281   2              hs--;
 282   2               if(hs==0)              //200ms jis up
 283   2                  hs=20,
 284   2                      ppd=1,
 285   2                  pt++;
 286   2        }
 287   1      }
 288          
 289          void timer2(void) interrupt 5                   //timer 2 over interrupt serive fution
 290          {TF2=0;
 291   1       sk=~sk;
 292   1      }
 293          
 294          /*主从机通信协议
 295            E1:按下开关1
 296            E2:按下开关2
 297            E3:按下开关3
 298            E4:按下开关4
 299            收到E1,E2,E3,E4分别回复E1,E2,E3,E4
 300            */
 301          
 302          
 303          void com(void) interrupt 4                              //serial port intterrup
C51 COMPILER V7.06   MY_COUSE                                                              05/12/2006 00:42:54 PAGE 6   

 304          {uchar tm,t1,t2;
 305   1       if(RI==1)              //receive 
 306   1        {RI=0;
 307   2         tm=SBUF;
 308   2         if(tm==0xAA)
 309   2           SBUF=0xBB;
 310   2         else if(tm==0xE1)
 311   2           kc=1,SBUF=0xE1;
 312   2         else if(tm==0xE2)
 313   2           kc=2,SBUF=0xE2;
 314   2         else if(tm==0xE3)
 315   2           kc=3,SBUF=0xE3;
 316   2         else if(tm==0xE4)
 317   2           kc=4,SBUF=0xE4;
 318   2         else  
 319   2           {t1=tm%16;
 320   3                t2=tm/16;
 321   3                SBUF=t1*16+t2;
 322   3               }
 323   2        }
 324   1       if(TI==1)
 325   1         TI=0;
 326   1      }
 327          
 328          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    700    ----
   CONSTANT SIZE    =    611    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     42    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      4    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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