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

📄 lcd40x4drv.lst

📁 64输入32输出单片机程序
💻 LST
字号:
C51 COMPILER V7.06   LCD40X4DRV                                                            08/22/2004 21:22:03 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE LCD40X4DRV
OBJECT MODULE PLACED IN LCD40X4DRV.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE LCD40X4DRV.C LARGE OPTIMIZE(7,SIZE) MODA2 DEBUG OBJECTEXTEND

stmt level    source

   1          //-------------------------------------------------------------------------
   2          //      Filename :  LCD40X4DRV.c
   3          //      Language :  C for AT89S53
   4          //      Revision :  1.0
   5          //  Date :      11/01/2004
   6          //  System clock :  24.00MHZ
   7          //-------------------------------------------------------------------------
   8          #include <..\atmel\at89s53.h>
   9          #include <absacc.h>
  10          #include <intrins.h>
  11          #include <dom12a.h>
  12          
  13          //-------------------------------------------------------------------------
  14          #define max_cols        40
  15          #define max_rows        4
  16          #define Out_Port        XBYTE[0x2000]
  17          #define DispPort    XBYTE[0x2001]
  18          //
  19          //  Routinues for 40x4 LCD Display.(4 bit data transfer)
  20          //  D7    D6   D5   D4   D3   D2   D1   D0
  21          //  D7    D6   D5   D4   NC   RS   E1   E0              //40x4
  22          //                                               E2       E1   NC       RS              //24X2
  23          //global variables for LCD Display
  24          uchar idata outp_buf =  0xff;
  25          uchar idata col, row;
  26          char  xdata strbuf[100];
  27          char  xdata *ptrbuf = strbuf;
  28          
  29          //external variables
  30          extern bit              keyDetectEnable;
  31          
  32          // function prototype --- Prefix with '_' as driver type
  33          void lcd_putchar(char c);
  34          void _set_display (char s, char d);
  35          void _initial_disp (void);
  36          void _clear_disp (void);
  37          void _lcdCursor_FlashToggling (char stFlashing);
  38          void _lcdCursorGoto(char r, char c);
  39          
  40          void _delay5ms (void);
  41          void _delay200us (void);
  42          void _delay100us (void);
  43          void _delay5us (void);
  44          
  45          //char _outp_stus (char num);
  46          //void _outp_bit (char num, char status);
  47          
  48          //-------------------------------------------------------------------------
  49          //
  50          //      Routinues for 40x4 LCD Display.
  51          //
  52          //*******************************************************************
  53          // putchar (basic version): expands '\n' into CR LF
  54          // switching % serial port & LCD display
  55          char putchar(char c)    // override of the built-in putchar
C51 COMPILER V7.06   LCD40X4DRV                                                            08/22/2004 21:22:03 PAGE 2   

  56          {
  57   1        //-------------LCD Display only
  58   1        //_delay100us();
  59   1        if ( c == '\n' ) {
  60   2                      c = ' ';
  61   2                      while ( col++ < max_cols) 
  62   2                              lcd_putchar(c);
  63   2                      col = 0;
  64   2                      if ( ++row >= max_rows )
  65   2                              row = 0;        //?????????? should scroll down???
  66   2                      _lcdCursorGoto(row, col);
  67   2        } else
  68   1                      lcd_putchar(c); 
  69   1        
  70   1        if ( ++col >= max_cols) {
  71   2                      col = 0;
  72   2                      if ( ++row >= max_rows )
  73   2                              row = 0;
  74   2                      _lcdCursorGoto(row, col);
  75   2        } // end if
  76   1        return (c);
  77   1      }  // end func.
  78          
  79          
  80          //******************************************************************
  81          void lcd_putchar(char c)
  82          {
  83   1        char buf = c;
  84   1        
  85   1        if ( row < 2) {
  86   2                      buf &= 0xf0;
  87   2              buf |= 0x04;
  88   2              DispPort = buf;
  89   2              buf |= 0x01;
  90   2              DispPort = buf;
  91   2              buf &= 0xfe;
  92   2              DispPort = buf;
  93   2              buf = (c<<4)&0xf0;
  94   2              buf |= 0x04;
  95   2              DispPort = buf;
  96   2              buf |= 0x01;
  97   2              DispPort = buf;
  98   2              buf &= 0xfe;
  99   2              DispPort = buf;
 100   2        } else {
 101   2                      buf &= 0xf0;
 102   2              buf |= 0x04;
 103   2              DispPort = buf;
 104   2              buf |= 0x02;
 105   2              DispPort = buf;
 106   2              buf &= 0xfd;
 107   2              DispPort = buf;
 108   2              buf = (c<<4)&0xf0;
 109   2              buf |= 0x04;
 110   2              DispPort = buf;
 111   2              buf |= 0x02;
 112   2              DispPort = buf;
 113   2              buf &= 0xfd;
 114   2              DispPort = buf;
 115   2        } // end else
 116   1        _delay100us();
 117   1      } // end func.
C51 COMPILER V7.06   LCD40X4DRV                                                            08/22/2004 21:22:03 PAGE 3   

 118          
 119          //-------------------------------------------------------------------------
 120          void _set_display (char s, char d)
 121          { // senting command/data to the LCD module
 122   1        // s: 0 -- upper, 1 -- lower
 123   1        char buf = d;
 124   1      
 125   1        switch (s) {
 126   2          case 0 :
 127   2              buf &= 0xf0;
 128   2              DispPort = buf;
 129   2              buf |= 0x01;
 130   2              DispPort = buf;
 131   2              buf &= 0xf0;
 132   2              DispPort = buf;
 133   2              buf = (d<<4);
 134   2              buf &= 0xf0;
 135   2              DispPort = buf;
 136   2              buf |= 0x01;
 137   2              DispPort = buf;
 138   2              buf &= 0xf0;
 139   2              DispPort = buf;
 140   2              _delay100us();
 141   2              break;
 142   2          case 1 :
 143   2              buf &= 0xf0;
 144   2              DispPort = buf;
 145   2              buf |= 0x02;
 146   2              DispPort = buf;
 147   2              buf &= 0xf0;
 148   2              DispPort = buf;
 149   2              buf = (d<<4);
 150   2              buf &= 0xf0;
 151   2              DispPort = buf;
 152   2              buf |= 0x02;
 153   2              DispPort = buf;
 154   2              buf &= 0xf0;
 155   2              DispPort = buf;
 156   2              _delay100us();
 157   2        } // end switch
 158   1      } // end func.
 159          
 160          //-------------------------------------------------------------------------
 161          void _initial_disp (void)
 162          { //initialize the LCD display
 163   1              unsigned char loop;
 164   1      
 165   1              _set_display(0, 0x30);  // 1st initial
 166   1              _set_display(1, 0x30);
 167   1          _delay5ms();
 168   1          _set_display(0, 0x30);      // 2nd initial
 169   1          _set_display(1, 0x30);
 170   1          _delay200us();
 171   1          _set_display(0, 0x30);  // 3rd initial
 172   1          _set_display(1, 0x30);
 173   1          _delay200us();
 174   1          _set_display(0, 0x20);  //
 175   1          _set_display(1, 0x20);
 176   1          _delay200us();
 177   1          _set_display(0, 0x2c);      // set display is 4bit data transfer.
 178   1          _set_display(1, 0x2c);
 179   1          _delay200us();
C51 COMPILER V7.06   LCD40X4DRV                                                            08/22/2004 21:22:03 PAGE 4   

 180   1          _set_display(0, 0x0f);      // display on
 181   1          _set_display(1, 0x0f);
 182   1          _delay200us();
 183   1          _set_display(0, 0x01);      // clear display
 184   1          _set_display(1, 0x01);
 185   1          _delay200us();
 186   1          _set_display(0, 0x06);      // entry mode.
 187   1          _set_display(1, 0x06);
 188   1          _delay5ms();
 189   1          _set_display(0, 0x0c);      // cursor off
 190   1          _set_display(1, 0x0c);      // cursor off
 191   1          _delay5ms();
 192   1      
 193   1          col = row = 0;
 194   1              DispPort |= 0xf0;
 195   1              for (loop=0; loop<10; loop++)
 196   1                      _delay5ms(); 
 197   1      } // end func.
 198          
 199          //-------------------------------------------------------------------------
 200          void _clear_disp (void)
 201          { // clear the LCD screen
 202   1      
 203   1          _set_display(0, 0x01);
 204   1          _set_display(1, 0x01);
 205   1              row = col = 0;
 206   1          _delay5ms();
 207   1      } // end func.
 208          
 209          //-------------------------------------------------------------------------
 210          void _lcdCursor_FlashToggling (char stFlashing)
 211          { // cursor flashing ON/OFF toggling
 212   1        uchar r;
 213   1        
 214   1        if ( row < 2) 
 215   1              r = 0;
 216   1        else
 217   1              r = 1;
 218   1      
 219   1        if (stFlashing)
 220   1                      _set_display(r, 0x0f);    // r row ON ,r=0 ,1&2 row r=1 3&4 row
 221   1        else
 222   1                      _set_display(r, 0x0c);    // r row OFF
 223   1      } // end func.
 224          
 225          //-------------------------------------------------------------------------
 226          void _lcdCursorGoto(char r, char c)
 227          {  
 228   1        row = r; col = c;
 229   1        switch(r){
 230   2           case 1:c |= 0xc0;
 231   2                              _set_display(0,c);
 232   2                          break;
 233   2           case 0:c |= 0x80;
 234   2                              _set_display(0,c);
 235   2                          break;
 236   2           case 3:c |= 0xc0;
 237   2                              _set_display(1,c);
 238   2                          break;
 239   2               case 2:c |= 0x80;
 240   2                              _set_display(1,c);
 241   2                          break;
C51 COMPILER V7.06   LCD40X4DRV                                                            08/22/2004 21:22:03 PAGE 5   

 242   2        } // end switch
 243   1      
 244   1      } // end func.
 245          
 246          //assume the uP works under 24MHz
 247          //-------------------------------------------------------------------------
 248          void _delay5ms(void)
 249          { 
 250   1        unsigned int tref = 900;
 251   1        while (tref != 0)
 252   1                      tref--;
 253   1      }
 254          //-------------------------------------------------------------------------
 255          void _delay200us (void)
 256          {
 257   1          char tref = 64;
 258   1          while (tref--);
 259   1      }
 260          //-------------------------------------------------------------------------
 261          void _delay100us (void)
 262          {
 263   1          char tref = 32;
 264   1          while (tref--);
 265   1      } // end func.


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    748    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =    102       6
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =      3    ----
   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 + -