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

📄 mn_lcm.lst

📁 C51模拟串口程序
💻 LST
字号:
C51 COMPILER V8.02   MN_LCM                                                                08/22/2006 20:56:47 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE MN_LCM
OBJECT MODULE PLACED IN MN_LCM.OBJ
COMPILER INVOKED BY: E:\电设计\keil\C51\BIN\C51.EXE MN_LCM.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include "reg51.h"
   2          #include "MN_LCM.h"
   3          sbit TT=P1^0;
   4          void Serial_Init(void)
   5          {
   6   1              TMOD|=0X02;
   7   1              TH0=0xa0;
   8   1              TL0=TH0;
   9   1              TR0=1;
  10   1              TF0=0;
  11   1      }
  12          void WaitTF0(void)
  13          {
  14   1              while(!TF0);
  15   1              TF0=0;
  16   1      }
  17          void WByte(uchar input)
  18          {
  19   1          //发送启始位
  20   1          uchar i=8;
  21   1          TR0=1;
  22   1              WaitTF0();
  23   1          TT=(bit)0;
  24   1          WaitTF0();
  25   1          //发送8位数据位
  26   1          while(i--)
  27   1          {
  28   2              TT=(bit)(input&0x01);     //先传低位
  29   2              WaitTF0();
  30   2              input=input>>1;
  31   2          }
  32   1          //发送校验位(无)
  33   1          //发送结束位
  34   1         TT=(bit)1;
  35   1          WaitTF0();
  36   1      } 
  37          //背光: 0开 1关
  38          void lcd_light(uchar light)
  39          {
  40   1              WByte(0x1b);
  41   1              WByte(0x25);
  42   1              WByte(light);}
  43          
  44          //清屏
  45          void lcd_cls(void)
  46          {
  47   1              WByte(0x1b);
  48   1              WByte(0x32);
  49   1      }
  50          
  51          //设置光标位置
  52          void lcd_cursor(uchar x, uchar y)      
  53          {
  54   1              WByte(0x1b);
  55   1              WByte(0x33);
C51 COMPILER V8.02   MN_LCM                                                                08/22/2006 20:56:47 PAGE 2   

  56   1              WByte(x);
  57   1              WByte(y);
  58   1      }
  59          
  60          //光标闪烁还是关闭
  61          void lcd_showcursor(uchar attr)   
  62          {
  63   1              WByte(0x1b);
  64   1              WByte(0x34);
  65   1              WByte(attr);
  66   1      }
  67          
  68          //显示字符串
  69          void lcd_string(uchar attr,uchar *pData) 
  70          {
  71   1              WByte(0x1b);
  72   1              WByte(0x37);
  73   1              WByte(attr);    
  74   1              for(;*pData!=0;pData++)         //遇到停止符0结束
  75   1              {
  76   2                      WByte(*pData);
  77   2              }
  78   1              WByte(0x00);
  79   1      }
  80          
  81          //画圆
  82          void lcd_circle(uchar attr,uchar ox,uchar oy,uchar rx)
  83          {
  84   1              WByte(0x1b);
  85   1              WByte(0x41);
  86   1              WByte(attr);
  87   1              WByte(ox);
  88   1              WByte(oy);
  89   1              WByte(rx);
  90   1      }
  91          
  92          //画线
  93          void lcd_line(uchar attr,uchar x0,uchar y0,uchar x1,uchar y1)
  94          {
  95   1              WByte(0x1b);
  96   1              WByte(0x39);
  97   1              WByte(attr);
  98   1              WByte(x0);
  99   1              WByte(y0);
 100   1              WByte(x1);
 101   1              WByte(y1);
 102   1      }
 103          
 104          //画点
 105          void lcd_dot(uchar attr,uchar x,uchar y)  
 106          {
 107   1              WByte(0x1b);
 108   1              WByte(0x38);
 109   1              WByte(attr);
 110   1              WByte(x);
 111   1              WByte(y);
 112   1      }
 113          
 114          /*-----------------------------------------
 115          功能:   任意位置显示一个汉字
 116                          输入汉字内码,坐标为像素
 117          -----------------------------------------*/
C51 COMPILER V8.02   MN_LCM                                                                08/22/2006 20:56:47 PAGE 3   

 118          void DisplayHZ(uchar x,uchar y,uchar ch1,uchar ch2) 
 119          {
 120   1              WByte(0x1b);
 121   1              WByte(0x3a);
 122   1          WByte(x);
 123   1          WByte(y);   
 124   1              WByte(ch1);
 125   1          WByte(ch2);
 126   1          
 127   1      }
 128          
 129          /*-----------------------------------------
 130          功能:   在指定的位置显示字符串  
 131          入口:   attr 0 正显 1 反显 
 132                  x 0--17 y 0--5
 133                  *string 字符串指针
 134          -----------------------------------------*/
 135          void DisplayStr(uchar attr,uchar x, uchar y,uchar *string)
 136          {
 137   1          lcd_cursor(x, y);
 138   1          lcd_string(attr,string);
 139   1      }
 140          
 141          /*-----------------------------------------
 142          功能:   在指定的位置显示16进制数
 143                          显示范围 00--FF
 144          -----------------------------------------*/
 145          void DisplayHex(uchar x, uchar y,uchar num)
 146          {
 147   1              uchar str[3];
 148   1              uchar tem;
 149   1              str[2]='\0';
 150   1              
 151   1              tem=num%16;
 152   1              num/=16;
 153   1          if(tem<10)
 154   1                  str[1] = tem+0x30;
 155   1          else
 156   1              str[1] = tem+0x30+7;
 157   1      
 158   1          if(num<10)
 159   1                  str[0] = num+0x30;
 160   1          else
 161   1              str[0] = num+0x30+7;
 162   1      
 163   1          DisplayStr(0,x,y,str);
 164   1      }
 165          /* 在指定位置显示10进制数  00-99  num为不大于99的数*/
 166          void DisplayShi(uchar x,uchar y,uchar num)
 167          {
 168   1              uchar str[3];
 169   1              uchar tem;
 170   1              str[2]='\0';
 171   1              tem=num%10;
 172   1              num/=10;
 173   1              str[1] = tem+0x30;
 174   1               str[0] = num+0x30;
 175   1               DisplayStr(0,x,y,str);
 176   1      }       
 177           
 178          /*-----------------------------------------
 179          功能:   在指定的位置显示浮点数
C51 COMPILER V8.02   MN_LCM                                                                08/22/2006 20:56:47 PAGE 4   

 180                          显示范围 00.00--99.99
 181          -----------------------------------------*/
 182          void DisplayFloat(uchar x, uchar y,float num)
 183          {
 184   1              uchar str[6];
 185   1              uchar tem,tem2,tem3,tem4;
 186   1              str[5]='\0';
 187   1              
 188   1              tem=num/10;
 189   1          num=num-tem*10;
 190   1          tem2=num;
 191   1          num=num-tem2;
 192   1          tem3=num*10;
 193   1          num=num-tem3*0.1;
 194   1          tem4=num*100;
 195   1      
 196   1          
 197   1          str[0] = tem+0x30;
 198   1              str[1] = tem2+0x30;
 199   1          str[2] = 0x2e;//.
 200   1              str[3] = tem3+0x30;
 201   1          str[4] = tem4+0x30;
 202   1      
 203   1          DisplayStr(0,x,y,str);
 204   1      }
 205          /*--------------------------------------------------
 206          显示一个3*5的字母或数字
 207          ---------------------------------------------*/
 208          void Display35(uchar x,uchar y,uchar CH)
 209          {
 210   1                      WByte(0x1b);
 211   1                      WByte(0x3b);
 212   1                      WByte(x);
 213   1                      WByte(y);
 214   1                      WByte(0x30+CH);
 215   1      }       
 216          
 217          
 218          
 219          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    718    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      40
   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 + -