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

📄 uart.lst

📁 口若悬河口若悬河口若悬河口若悬河口若悬河口若悬河口若悬河口若悬河口若悬河
💻 LST
字号:
C51 COMPILER V8.02   UART                                                                  08/24/2008 10:48:13 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE UART
OBJECT MODULE PLACED IN .\UART.obj
COMPILER INVOKED BY: C:\Keil\uv3\C51\BIN\C51.EXE ..\UART.C BROWSE DEBUG OBJECTEXTEND OBJECT(.\UART.obj)

line level    source

   1          /*********串口调试,并于LCD显示************/
   2          #include <reg51.H>
   3          #define uchar unsigned char 
   4          uchar code dispcode1[]={"2008-08-24 00:00"};
   5          uchar code dispcode2[]={"~Yang wen chong~"};
   6          uchar seg[]={"0123456789"};
   7          uchar recwrong[]={"error send again"};
   8          uchar i,j,k,l,DData;
   9          sbit RS=P1^1;
  10          sbit RW=P1^0;
  11          sbit E=P1^2;
  12          uchar t,m=0,tm11s=0;
  13          unsigned int tcounter=0;//计时
  14          
  15          /**********T0中断*************/
  16          void timer0() interrupt 1
  17          {
  18   1      unsigned char t;
  19   1      TL0=0x78;TH0=0x4c;
  20   1      t++;
  21   1      //TF1=0;
  22   1      if(t==20)
  23   1      {t=0;
  24   2      tm11s=1;
  25   2      tcounter++;
  26   2      if(tcounter==3601)         //重置0
  27   2       {
  28   3       tcounter=0;}
  29   2      }
  30   1      }
  31          
  32          /*****延时******/
  33          void delay()
  34          {for(l=0;l<=100;l++){}}
  35          
  36          
  37          /*******写命令时序*********/
  38          void write_com() //write order
  39          {
  40   1          RS=0;RW=0;E=0;E=0;delay();
  41   1              E=1;
  42   1      }
  43          
  44          /********写数据时序*******/
  45          void write_data() //write data
  46          {
  47   1          RS=1;RW=0;E=0;E=0;delay();
  48   1              E=1;
  49   1      }
  50          
  51          /******初始化LCD*****/
  52          void initializtion()    //lcd initializtion
  53          {                                                                        
  54   1          for(i=0;i<=100;i++) //初始化LCD需先延时
  55   1          P0=0x01;write_com();  //开显示器
C51 COMPILER V8.02   UART                                                                  08/24/2008 10:48:13 PAGE 2   

  56   1          P0=0x38;write_com();
  57   1          P0=0x0c;write_com();
  58   1          P0=0x06;write_com();
  59   1      }
  60          
  61          
  62          /*********LCD显示部分*********/
  63          void Display(m,DData)    // display data
  64          {
  65   1           P0=0xC0+m;     //write address
  66   1           write_com();
  67   1               //P0=0x14;
  68   1               //write_com();
  69   1           P0=DData;     //write data
  70   1           write_data();
  71   1      }
  72          
  73          
  74          
  75          /********串口接收中断服务程序********/
  76          void Esisr() interrupt 4    //串口接收中断服务程序
  77          {
  78   1          
  79   1      uchar temp;
  80   1      ES=0;     //先把中断关掉
  81   1      if(RI == 1)
  82   1      {   
  83   2          RI = 0;
  84   2          temp = SBUF; //接收数据
  85   2          SBUF=temp;      //将接收到的数据发送至PC机
  86   2          Display(m,temp);    //将接收到的数据送LCD显示,m从0开始
  87   2          while(!TI);    //等待数据发送完成
  88   2          TI=0;
  89   2          m++;
  90   2          if((m>15)||(temp=='\0'))   //逻辑或,一个真则真
  91   2          m=0;
  92   2      }
  93   1          ES=1;          //开中断
  94   1      }
  95          
  96          
  97          /********初始化T0、T1***********/
  98          void system_initial(void)     //system initializtion
  99          {
 100   1           TMOD=0x21;// 定时器1工作方式2,定时器0工作方式1
 101   1           PCON=0x00;//数据传输率选择,0倍频。
 102   1           SCON=0x50;//串口工作方式选择,并打开接收允许。SM0SM1SM2:010(8位异步串行通信方式,不用帧错误(SOCN^7)
             -)
 103   1           TH1=0xfa;//定时器赋初值。
 104   1           TL1=0xfa;//波特率4800bit/s
 105   1           TL0=0x78;TH0=0x4c;   //20ms
 106   1               TR1=1;//启动定时器。
 107   1               TR0=1;
 108   1               ET0=1;
 109   1               IPH=0x10;
 110   1               PS=1;//串口中断优先级较T0高
 111   1               EA = 1;     //开总中断
 112   1           ES = 1;  //开串口中断
 113   1      }
 114          
 115          
 116          /*********主函数**********/
C51 COMPILER V8.02   UART                                                                  08/24/2008 10:48:13 PAGE 3   

 117          void main()
 118          {
 119   1           initializtion();
 120   1           P0=0x80;
 121   1               write_com();   //第一行第一个地址
 122   1           for(j=0;j<=15;j++)
 123   1           {
 124   2           P0=dispcode1[j];
 125   2           write_data();
 126   2           }
 127   1           P0=0xC0;
 128   1               write_com();
 129   1           for(k=0;k<=15;k++)
 130   1           {
 131   2           P0=dispcode2[k];
 132   2           write_data();
 133   2           }
 134   1           system_initial();  //T1、串口中断
 135   1           while(1)
 136   1               {
 137   2               if(tm11s)
 138   2               {
 139   3               tm11s=0;
 140   3               P0=0x8b;
 141   3               write_com();
 142   3               P0=seg[(tcounter/60)/10];//分十位
 143   3               write_data();
 144   3               P0=seg[(tcounter/60)%10]; //分个位
 145   3               write_data();
 146   3               P0=0x8e;
 147   3               write_com();
 148   3               P0=seg[(tcounter%60)/10];//秒十位
 149   3               write_data();
 150   3               P0=seg[(tcounter%60)%10]; //秒个位
 151   3               write_data();
 152   3               SBUF=P0;
 153   3                while(!TI);    //等待数据发送完成
 154   3            TI=0;}}
 155   1      }
 156          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    443    ----
   CONSTANT SIZE    =     34    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     38       1
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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