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

📄 lcd.lst

📁 新手上路
💻 LST
字号:
C51 COMPILER V7.50   LCD                                                                   01/22/2007 11:02:46 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE lcd.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /* lcd.c
   2          *
   3          *
   4          */
   5          #include "intrins.h"
   6          #include "STC89C51RC.H"
   7          #include "lcd.h"
   8          
   9          unsigned char pdata disp_buffer[15];//1621显示缓存
  10          unsigned int code character[] = //注:最高位为C笔划判断位
  11          {
  12          0x8998,0x0040,0x039a,0x829a,0x8a0a,0x8a92,0x8b92,0x8088,//0,1,2,3,4,5,6,7,
  13          0x8b9a,0x8a9a,0x0000,0x8b8a,0x80da,0x0990,0x80d8,0x0b92,//8,9, ,a,b,c,d,e, 第三个是空格
  14          0x0b82,0x8992,0x8b0a,0x00d0,0x8018,0x0045,0x0910,0x8d0c,//f,g,h,i,j,k,l,m,
  15          0x892c,0x8998,0x0b8a,0x8999,0x0b8b,0x8a92,0x00c0,0x8918,//n,o,p,q,r,s,t,u,
  16          0x0924,0x8929,0x0425,0x8a1a,0x00b4,0x8fff//v,w,x,y,z,*,第六个是全显
  17          };
  18          /***************************************
  19          功能:初始化LCD
  20          描叙:每次上电都需要初始化LCD
  21          参数:无
  22          返回:无
  23          调用:void lcd_write_13(unsigned int)
  24          ***************************************/
  25          void lcd_init()
  26          {
  27   1              lcd_write_13(LCD_EN);//LCD使能
  28   1              lcd_write_13(LCD_BIAS_COM);//设置BIAS和COM,因为这句搞死我了
  29   1              lcd_clrall();//把所有显示清除
  30   1              lcd_write_13(LCD_ON);//LCD显示开
  31   1      }
  32          
  33          /***************************************
  34          功能:显示所有点
  35          描叙:点亮所有可以显示的点
  36          参数:无
  37          返回:无
  38          调用:lcd_update(0x00,15);
  39          耗时:
  40          ***************************************
  41          void lcd_dispall()
  42          {
  43                  unsigned char i;
  44                  for(i = 14; i > 0; i--)//把显示缓冲全部清0
  45                  {
  46                          disp_buffer[i] = 0xff;
  47                  }
  48                  lcd_update(0,15);//把显示缓冲数据全部送给LCD
  49          }*/
  50          
  51          /***************************************
  52          功能:清除所有显示
  53          描叙:清除所有可以显示的点
  54          参数:无
  55          返回:无
C51 COMPILER V7.50   LCD                                                                   01/22/2007 11:02:46 PAGE 2   

  56          调用:lcd_update(0x00,15);
  57          耗时:
  58          ***************************************/
  59          void lcd_clrall()
  60          {
  61   1              unsigned char i;
  62   1              for(i = 15; i > 0; i--)//
  63   1              {
  64   2                      disp_buffer[i-1] = 0x00;
  65   2              }
  66   1      /*      unsigned char j = 0;
  67   1              for(i = 15; i > 0; i--)//把显示缓冲全部清0
  68   1              {
  69   1                      disp_buffer[j] = 0x00;
  70   1                      j++;
  71   1              }*/
  72   1              lcd_update(0,15);//把显示缓冲数据全部送给LCD
  73   1      }
  74          /***************************************
  75          功能:写13位数据至HT1621
  76          描叙:写半个字节至指定地址,写命令需要用此函数
  77          参数:j需要送出去的13位数据
  78          返回:无
  79          耗时:196US
  80          ***************************************/
  81          void lcd_write_13(unsigned int j)
  82          {
  83   1              unsigned char i;
  84   1              HT1621_CS = 0;
  85   1              _nop_();
  86   1              _nop_();
  87   1              _nop_();
  88   1              _nop_();
  89   1              for(i = 13; i > 0; i--)
  90   1              {
  91   2                      HT1621_CLK = 0;
  92   2                      HT1621_DAT = j & 0x1000;//读取j的第4位
  93   2                      j <<= 1;
  94   2                      _nop_();
  95   2                      _nop_();
  96   2                      _nop_();
  97   2                      HT1621_CLK = 1;
  98   2                      _nop_();
  99   2                      _nop_();
 100   2                      _nop_();
 101   2                      _nop_();
 102   2              }
 103   1              HT1621_CS = 1;
 104   1              _nop_();
 105   1              _nop_();
 106   1              _nop_();
 107   1              _nop_();
 108   1      }
 109          
 110          /***************************************
 111          功能:从显示缓冲中写部分数据至LCD
 112          描叙:连续写数据至HT1621显示
 113          参数:缓冲数组起始下标,字节数,
 114          返回:无
 115          调用:
 116          耗时:不确定,根据需要写数据多少来确定
 117          ***************************************/
C51 COMPILER V7.50   LCD                                                                   01/22/2007 11:02:46 PAGE 3   

 118          void lcd_update(unsigned char s_byte_add,unsigned char num)
 119          {
 120   1              unsigned char i,j;
 121   1              unsigned int a;
 122   1              a = (s_byte_add << 1) | 0x0140;//把缓冲字节地址拆开,把地址前面加上101
 123   1              HT1621_CS = 0;
 124   1              _nop_();
 125   1              _nop_();
 126   1              _nop_();
 127   1              _nop_();
 128   1              for(i = 9; i > 0; i--)//发送101加6位起始地址
 129   1              {
 130   2                      HT1621_CLK = 0;
 131   2                      HT1621_DAT = a & 0x0100;//读第8位送给数据线
 132   2                      a <<= 1;
 133   2                      _nop_();
 134   2                      _nop_();
 135   2                      _nop_();
 136   2                      HT1621_CLK = 1;
 137   2                      _nop_();
 138   2                      _nop_();
 139   2                      _nop_();
 140   2                      _nop_();
 141   2              }
 142   1              for(num; num > 0; num--)
 143   1              {
 144   2                      j = disp_buffer[s_byte_add];//数组里保存要送往1621RAM的数据
 145   2                      s_byte_add++;
 146   2                      for(i = 8; i > 0; i--)
 147   2                      {
 148   3                              HT1621_CLK = 0;
 149   3                              HT1621_DAT = j & 0x80;//读取最高位
 150   3                              j <<= 1;
 151   3                              _nop_();
 152   3                              _nop_();
 153   3                              _nop_();
 154   3                              HT1621_CLK = 1;
 155   3                              _nop_();
 156   3                              _nop_();
 157   3                              _nop_();
 158   3                              _nop_();
 159   3                      }
 160   2              }
 161   1              HT1621_CS = 1;
 162   1              _nop_();
 163   1              _nop_();
 164   1              _nop_();
 165   1              _nop_();
 166   1      }
 167          
 168          /***************************************
 169          功能:写LCD上的16个单独显示单元
 170          描叙:
 171          参数:x写前8位为0后8位为1,w写还是清除,y要显示的位
 172          返回:无
 173          调用:
 174          耗时:
 175          ***************************************/
 176          /*void write_bit(bit x,bit w,unsigned char y)
 177          {
 178                  unsigned char a;
 179                  if(x)a = 14;
C51 COMPILER V7.50   LCD                                                                   01/22/2007 11:02:46 PAGE 4   

 180                  else a = 0;
 181                  
 182          }*/
 183          
 184          /***************************************
 185          功能:写LCD上的8个字符
 186          描叙:
 187          参数:写某位,显示什么
 188          返回:无
 189          调用:fine_char1();fine_char2();
 190          耗时:
 191          ***************************************/
 192          void write_char(unsigned char x,unsigned char Char)//空格的ASCII是0x20,怎么办?
 193          {
 194   1      //      if(Char == 29)Char = 10;
 195   1              if(Char > 60)Char -= 54;//为了使26个字母对应字库11至36
 196   1              switch(x)
 197   1              {
 198   2                      case 1: fine_char1(1,2,Char);
 199   2                      break;
 200   2                      case 2: fine_char2(2,3,Char);
 201   2                      break;
 202   2                      case 3: fine_char1(4,5,Char);
 203   2                      break;
 204   2                      case 4: fine_char2(5,6,Char);
 205   2                      break;
 206   2                      case 5: fine_char1(8,9,Char);
 207   2                      break;
 208   2                      case 6: fine_char2(9,10,Char);
 209   2                      break;
 210   2                      case 7: fine_char1(11,12,Char);
 211   2                      break;
 212   2                      case 8: fine_char2(12,13,Char);
 213   2                      break;
 214   2                      default:break;
 215   2              }
 216   1              if(character[Char] & 0x8000) disp_buffer[7] |= (0x80 >> --x);
 217   1              else disp_buffer[7] &= ~(0x80 >> --x);
 218   1              lcd_update(7,1);//把C笔划刷新
 219   1      }
 220          
 221          /***************************************
 222          功能:采用这两个函数又省下200多字节CODE
 223          描叙:只被write_char调用,计算出显示数据并刷新LCD
 224          参数:要写的字符在缓冲数组A,B下标中,Char是要显示的字符下标
 225          返回:无
 226          调用:
 227          耗时:
 228          ***************************************/
 229          void fine_char1(unsigned char a,unsigned char b,unsigned char Char)
 230          {
 231   1              unsigned int temp;
 232   1              temp = 0x000f & disp_buffer[b];//
 233   1              temp += character[Char] << 4;
 234   1              disp_buffer[a] = temp >> 8;
 235   1              disp_buffer[b] = temp & 0x00ff;
 236   1              lcd_update(a,2);
 237   1      }
 238          
 239          /***************************************
 240          功能:采用这两个函数又省下200多字节CODE
 241          描叙:只被write_char调用,计算出显示数据并刷新LCD
C51 COMPILER V7.50   LCD                                                                   01/22/2007 11:02:46 PAGE 5   

 242          参数:要写的字符在缓冲数组A,B下标中,Char是要显示的字符下标
 243          返回:无
 244          调用:
 245          耗时:
 246          ***************************************/
 247          void fine_char2(unsigned char a,unsigned char b,unsigned char Char)
 248          {
 249   1              unsigned int temp;
 250   1              temp = (0x00f0 & disp_buffer[a]) << 8;//
 251   1              temp += (0x0fff & character[Char]);
 252   1              disp_buffer[a] = temp >> 8;
 253   1              disp_buffer[b] = temp & 0x00ff;
 254   1              lcd_update(a,2);
 255   1      }
 256          
 257          /***************************************
 258          功能:写字符串
 259          描叙:
 260          参数:起始位,字符串指针
 261          返回:无
 262          调用:write_char(x,*p);
 263          耗时:
 264          ***************************************
 265          void write_string(unsigned char x,unsigned char *p)
 266          {
 267                  while(*p)
 268                  {
 269                          write_char(x,*p);
 270                          x++;
 271                          p++;
 272                  }
 273          }*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    508    ----
   CONSTANT SIZE    =     76    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =     15    ----
   DATA SIZE        =   ----       2
   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 + -