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

📄

📁 mcs51单片机使用串口进行通信
💻
字号:
C51 COMPILER V7.07   _笃诖_码                                                              11/19/2008 12:54:44 PAGE 1   


C51 COMPILER V7.07, COMPILATION OF MODULE _笃诖_码
OBJECT MODULE PLACED IN 后期代码.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE 后期代码.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          #define uchar unsigned char 
   2          
   3          #include "string.h" 
   4          
   5          #include "reg51.h" 
   6          sbit P1_0=P1^0;
   7          sbit P1_1=P1^1;
   8          sbit P1_7=P1^7;
   9          sbit P1_6=P1^6;
  10          sbit P1_5=P1^5;
  11          sbit P1_4=P1^4;
  12          sbit P1_3=P1^3;
  13          sbit P1_2=P1^2;
  14          
  15          void SendData(uchar Dat) 
  16          
  17          {       uchar i=0; 
  18   1      
  19   1              SBUF=Dat; 
  20   1      
  21   1              while(1){ 
  22   2                      if(TI)  
  23   2                      {        TI=0;
  24   3                               break;
  25   3                      }
  26   2              }
  27   1       
  28   1      
  29   1      } 
  30          
  31          void mDelay(unsigned int DelayTime) 
  32          { unsigned char j=0; 
  33   1      
  34   1              for(;DelayTime>0;DelayTime--) 
  35   1              { 
  36   2                      for(j=0;j<125;j++) 
  37   2                      {;}     
  38   2              } 
  39   1      
  40   1      } 
  41          
  42          uchar Key() 
  43          {                
  44   1              uchar row,colum;
  45   1              P2 = 0x0f;
  46   1              if( P2 != 0x0f)
  47   1              {
  48   2                      if(P2 == 0x07) row = 0;
  49   2                      if(P2 == 0x0b) row = 1;
  50   2                      if(P2 == 0x0d) row = 2;
  51   2                      if(P2 == 0x0e) row = 3;
  52   2      
  53   2                      P2 = 0xf0;
  54   2                      if(P2 != 0xf0)
  55   2                      {
C51 COMPILER V7.07   _笃诖_码                                                              11/19/2008 12:54:44 PAGE 2   

  56   3                              if(P2 == 0x70) colum = 0;
  57   3                              if(P2 == 0xb0) colum = 1;
  58   3                              if(P2 == 0xd0) colum = 2;
  59   3                              if(P2 == 0xe0) colum = 3;
  60   3                              
  61   3                              P2 = 0x0f;
  62   3                              while(P2 != 0x0f);
  63   3                              return (row*4+colum);
  64   3                      }
  65   2                      else 
  66   2                              return (0xff);
  67   2              }
  68   1      
  69   1              return(0xff); 
  70   1      } 
  71          
  72          void main() 
  73          { 
  74   1                      uchar KeyValue; 
  75   1                      uchar KeyTemp;
  76   1                      uchar Get;
  77   1      
  78   1                      TMOD=0x20;              //确定定时器工作模式 
  79   1                      TH1=0xe8; 
  80   1                      TL1=0xe8;               //定时初值 
  81   1                      PCON&=0x80;             //SMOD=1 
  82   1                      TR1=1;                          //开启定时器 1
  83   1                      SCON=0x40;               //串口工作方式 1 
  84   1                      REN=1;                          //允许接收 
  85   1                      
  86   1                      P1_5 = 0;
  87   1                      P1_6 = 0;
  88   1                      P1_7 = 0;
  89   1                      P1_0 = 0;
  90   1                      P1_1 = 0;
  91   1                      P1_2 = 0;
  92   1                      
  93   1                      KeyTemp = 0xff;
  94   1                      for(;;) 
  95   1                      { 
  96   2                      
  97   2              //              KeyValue = Key();
  98   2                              
  99   2              //              if(KeyValue != 0xff)
 100   2              //                      KeyTemp = KeyValue;
 101   2      
 102   2                              if(RI)
 103   2                              {
 104   3                                      Get =  SBUF;
 105   3      
 106   3                                      if(Get == 0) {P1_0=1; P1_1=0; P1_2=0;}
 107   3                              //      if(Get == 1) {P1_1=1; P1_0=0; P1_2=0;}
 108   3                              //      if(Get == 2) {P1_2=1; P1_0=0; P1_1=0;}
 109   3                                      P1_1 = 1;
 110   3                                      if(Get == 4) 
 111   3                                      {
 112   4                                              P1_2=1;
 113   4                                              P1_7=1;
 114   4                                              mDelay(0x01);
 115   4                                              SendData(0x77);
 116   4                                              mDelay(0x01);
 117   4                                              P1_7=0;
C51 COMPILER V7.07   _笃诖_码                                                              11/19/2008 12:54:44 PAGE 3   

 118   4                                      }
 119   3                                      
 120   3                      //              KeyTemp = 0xff;
 121   3                                      RI=0;
 122   3                              }       
 123   2                      } 
 124   1      } 
*** WARNING C280 IN LINE 74 OF 后期代码.C: 'KeyValue': unreferenced local variable


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    212    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       3
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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