C51 COMPILER V7.06   TEXT1                                                                 04/30/2012 12:50:04 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE TEXT1
OBJECT MODULE PLACED IN .\Text1.OBJ
COMPILER INVOKED BY: D:\keil\C51\BIN\C51.EXE .\Text1.c DEBUG OBJECTEXTEND

stmt level    source

   1          #include <reg51.h>
   2          #define uchar unsigned char
   3          #define uint unsigned int
   4          sbit p21=P2^1;//按键端口
   5          uint j,f;
   6          uchar dat[]={0xff,0x00,0x18,0x3c,0x7e,0xff,0x7e,0x3c,0x18,0x00};//发送控制LED的十六进制的数
   7          
   8          void delay(uint x)
   9          {
  10   1          uint k;
  11   1          while(x--)
  12   1               {
  13   2              for(k=120;k>0;k--);
  14   2          }
  15   1      }
  16          
  17          void serial_init() //using 0 中断初始化
  18          {
  19   1          P1=0x00;
  20   1              p21=1;
  21   1          SCON=0x50;//工作在方式1下，REN设置为允许接收
  22   1              PCON=0x00;//不加倍
  23   1              TMOD=0x20;//自动重装初值，波特率：9600
  24   1              TH1=0xfd;
  25   1              TL1=0xfd;
  26   1              TR1=1;//开启定时器
  27   1              EA=1;//开启总中断
  28   1              ES=1;//开启串口中断
  29   1      }
  30          
  31          void serial_inte() interrupt 4 //中断函数
  32          {
  33   1          ES=0;
  34   1               if(TI==0)
  35   1               {
  36   2                   RI=0;
  37   2                        P1=SBUF;
  38   2      /*               for(f=0;f<10;f++)
  39   2                       {
  40   2                           str[f]=SBUF;
  41   2                           f++;
  42   2                                P1=str[f];
  43   2                       }*/
  44   2               }
  45   1               ES=1;
  46   1      }
  47          
  48          void main()
  49          {
  50   1          uint i,t;
  51   1               P1=0xff;
  52   1               serial_init();//串口初始化
  53   1          while(1)
  54   1               {
  55   2                   for(i=0;i<9;)
C51 COMPILER V7.06   TEXT1                                                                 04/30/2012 12:50:04 PAGE 2   

  56   2                        {
  57   3                            t=p21;
  58   3                            delay(1);//延时去抖动
  59   3                            if(p21==t&&p21==0)//再次判断是否按下
  60   3                  {
  61   4                                          while(!p21);//判断是否弹起
  62   4                      SBUF=dat[i];
  63   4                           while(!TI);
  64   4                           TI=0;
  65   4                      i++;
  66   4                                          delay(100);
  67   4                            }
  68   3                   }
  69   2               }
  70   1      }
  71          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    155    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     14       4
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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