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

📄 dgl.lst

📁 lcd208*80点阵的,ic为爱普生的D15721E,lcd驱动程序.
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.09   DGL                                                                   04/15/2008 09:53:26 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE DGL
OBJECT MODULE PLACED IN dgl.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE dgl.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg52.h>
   2          
   3          
   4          sbit   CS=P1^0;
   5          sbit  RES=P1^1;
   6          sbit   A0=P1^2;
   7          sbit  SCL=P1^3;
   8          sbit   SI=P1^4;
   9          
  10          unsigned char code beijing2008[192];
  11          unsigned char code pp[350];
  12          unsigned char code cir[200];
  13          void Delay(unsigned int i)
  14          {
  15   1        unsigned int c;
  16   1      
  17   1        while(i--)
  18   1          {
  19   2           c=1000 ;
  20   2           while(c--);      
  21   2      
  22   2          }
  23   1      
  24   1      }
  25          
  26          void SpisendData(char c)
  27          {
  28   1        unsigned char i;
  29   1      
  30   1       CS=0;
  31   1       A0=1;
  32   1      
  33   1       for(i=0x80;i>0;i=i>>1)
  34   1         {
  35   2          SCL=0;
  36   2          SI=(i&c);
  37   2          SCL=1;
  38   2         }
  39   1       CS=1;
  40   1      
  41   1      }
  42          
  43          void SpisendCode(char c)
  44          {
  45   1       unsigned char i;  
  46   1      
  47   1       CS=0;
  48   1       A0=0;
  49   1      
  50   1       for(i=0x80;i>0;i=i>>1)
  51   1         {
  52   2          SCL=0;
  53   2          SI=(i&c);
  54   2          SCL=1;
  55   2         }
C51 COMPILER V7.09   DGL                                                                   04/15/2008 09:53:26 PAGE 2   

  56   1       CS=1;
  57   1       
  58   1      }
  59          
  60          void LcdInitial()
  61          {
  62   1       RES=0;
  63   1       Delay(30);
  64   1       RES=1; 
  65   1      SpisendCode(0xae);Delay(1);  //display off也是reset后默认的
  66   1      SpisendCode(0xa6);Delay(1);  //display normal也是reset后默认的 reverse(0xc7)
  67   1      SpisendCode(0xa4);Delay(1);  //full display 也是reset后默认的 xxxxxxxxxxxxxxx
  68   1      SpisendCode(0xc5);Delay(1);  //Common Output Status Select,default:normal(0xc4),now adverse(0xc5)
  69   1      SpisendCode(0xa0);Delay(1);  //Column Address Set Direction:default:normal
  70   1      
  71   1      SpisendCode(0x66);Delay(1);  //mode and dummy perial select:00,also default
  72   1      SpisendData(0x00);Delay(1);
  73   1      
  74   1      SpisendCode(0x39);Delay(1);  //Gray-scale Pattern Set 
  75   1      SpisendData(0x43);Delay(1);  //选中间色*******************32
  76   1      
  77   1      SpisendCode(0x6d);Delay(1);    //Display Line Number Set
  78   1      SpisendData(0x19);Delay(1);   //total 81 lines,also default,xxxxxxxxxxxxxxx     
  79   1      SpisendData(0x00);Delay(1);   //start line
  80   1      
  81   1      SpisendCode(0xe7);Delay(1);   // MLS drive selection
  82   1      SpisendData(0x0b);Delay(1);   //use default
  83   1      
  84   1      
  85   1      SpisendCode(0x36);Delay(1);  //nline inverted:n=4,also default;
  86   1      SpisendData(0x12);Delay(1);
  87   1      SpisendCode(0xe5);Delay(1);  //n-line Inverting Drive ON/OFF,default is off(0xe4),now is on(0xe5)  xxxxxxx
             -xx
  88   1      
  89   1      
  90   1      SpisendCode(0x5f);Delay(1);   //frequence select
  91   1      SpisendData(0x0);Delay(1);   //not the defalut,fcl=171khz,ffr=81hz,原0x08
  92   1      SpisendCode(0xab);Delay(1);   //os on
  93   1      
  94   1      
  95   1      SpisendCode(0x2b);Delay(1);  //adjust v3
  96   1      SpisendData(0x07);Delay(1);  //v3:9~16
  97   1      SpisendCode(0x81);Delay(1);  //v3 volume
  98   1      SpisendData(0x43);Delay(1);  //alfa=larger 00xxxxxxxxxxxxxxxxxxxxx
  99   1      
 100   1      SpisendCode(0x4e);Delay(1);  //Temperature Gradient Set :use default
 101   1      SpisendData(0x00);Delay(1);  
 102   1      SpisendCode(0x28);Delay(1);  //Thermal sensor ON/OFF:is off
 103   1      
 104   1      
 105   1      
 106   1      SpisendCode(0xa2);Delay(1);  //lcd bias
 107   1      SpisendData(0x00);Delay(1);  //  1/8
 108   1      
 109   1      SpisendCode(0x25);Delay(1);  //power control,mode set
 110   1      SpisendData(0x04);Delay(1);
 111   1      SpisendCode(0x25);Delay(1);  //power control,mode set
 112   1      SpisendData(0x06);Delay(1);
 113   1      SpisendCode(0x25);Delay(1);  //power control,mode set
 114   1      SpisendData(0x07);Delay(1);
 115   1      }
 116          
C51 COMPILER V7.09   DGL                                                                   04/15/2008 09:53:26 PAGE 3   

 117          void ScanScreen()
 118          {
 119   1       unsigned char i,j;
 120   1      SpisendCode(0xaf);Delay(1);  //display on也是reset后默认的
 121   1      SpisendCode(0xa0);Delay(1);  //Column Address Set Direction:default:normal
 122   1      
 123   1      SpisendCode(0x6d);Delay(1);   //Display Line Number Set
 124   1      SpisendData(0x13);Delay(1);   //total 19page,81 lines,also default,xxxxxxxxxxxxxxx     
 125   1      SpisendData(0x00);Delay(1);   //start line
 126   1      SpisendCode(0x84);Delay(1);   //display data input directon select:comlumn优先
 127   1      
 128   1      for(i=0;i<20;i=i+4)             //页的地址,共20pages,when use gray mode
 129   1        {
 130   2               SpisendCode(0xb1);  //page address write commond
 131   2               SpisendData(i);;     //page address 
 132   2               SpisendCode(0x13);  //column address write commond
 133   2               SpisendData(0);     //column address   
 134   2          for(j=0;j<208;j++)         //column address 
 135   2             {        
 136   3               SpisendCode(0x1d);;   //data write commond
 137   3               SpisendData(0x00);   //data 
 138   3               }      
 139   2               
 140   2               
 141   2               SpisendCode(0xb1);  //page address write commond
 142   2               SpisendData(i+1);;     //page address 
 143   2               SpisendCode(0x13);  //column address write commond
 144   2               SpisendData(0);     //column address   
 145   2         for(j=0;j<208;j++)         //column address 
 146   2             {        
 147   3               SpisendCode(0x1d);;   //data write commond
 148   3               SpisendData(0x55);   //data 
 149   3               }
 150   2               
 151   2                               
 152   2             SpisendCode(0xb1);  //page address write commond
 153   2               SpisendData(i+2);;     //page address 
 154   2               SpisendCode(0x13);  //column address write commond
 155   2               SpisendData(0);     //column address   
 156   2         for(j=0;j<208;j++)         //column address 
 157   2             {        
 158   3               SpisendCode(0x1d);;   //data write commond
 159   3               SpisendData(0xaa);   //data 
 160   3               }      
 161   2               
 162   2                        
 163   2               SpisendCode(0xb1);  //page address write commond
 164   2               SpisendData(i+3);;     //page address 
 165   2               SpisendCode(0x13);  //column address write commond
 166   2               SpisendData(0);     //column address   
 167   2         for(j=0;j<208;j++)         //column address 
 168   2             {        
 169   3               SpisendCode(0x1d);;   //data write commond
 170   3               SpisendData(0xff);   //data 
 171   3               }      
 172   2      
 173   2       }
 174   1      
 175   1      }
 176          
 177          void ClearScreen()
 178          {
C51 COMPILER V7.09   DGL                                                                   04/15/2008 09:53:26 PAGE 4   

 179   1        unsigned char i,j;
 180   1      
 181   1      SpisendCode(0xaf);Delay(1);  //display on也是reset后默认的
 182   1      SpisendCode(0xa0);Delay(1);  //Column Address Set Direction:default:normal
 183   1      
 184   1      SpisendCode(0x6d);Delay(1);   //Display Line Number Set
 185   1      SpisendData(0x13);Delay(1);   //total 19page,81 lines,also default,xxxxxxxxxxxxxxx     
 186   1      SpisendData(0x00);Delay(1);   //start line
 187   1      SpisendCode(0x84);Delay(1);   //display data input directon select:comlumn优先
 188   1      
 189   1      for(i=0;i<20;i++)             //页的地址,共20pages,when use gray mode
 190   1        { 
 191   2           SpisendCode(0xb1);  //page address write commond
 192   2           SpisendData(i);     //page address 
 193   2           SpisendCode(0x13);  //column address write commond
 194   2           SpisendData(0);     //column address  
 195   2        for(j=208;j>0;j--)    
 196   2           {  
 197   3            
 198   3               SpisendCode(0x1d);   //data write commond
 199   3               SpisendData(0x00);   //data 
 200   3           }
 201   2        }
 202   1      
 203   1      }
 204          //
 205          char Half_Char(char c)
 206          {
 207   1       char a1,a2,a3,a4;
 208   1      //c为一个字节的第四位,扩展成一个灰度的字节
 209   1       if(c&0x08)a1=3;
 210   1       else a1=0;
 211   1       if(c&0x04)a2=3;
 212   1       else a2=0;
 213   1       if(c&0x02)a3=3;
 214   1       else a3=0;
 215   1       if(c&0x01)a4=3;
 216   1       else a4=0;
 217   1      
 218   1       a4=(a1<<6)+(a2<<4)+(a3<<2)+a4;
 219   1      
 220   1       return a4;
 221   1      }
 222          //=================================
 223          char Grayhalf_Char(char c,unsigned char graymode)
 224          {
 225   1       char a1,a2,a3,a4;
 226   1      //c为一个字节的第四位,扩展成一个灰度的字节
 227   1       if(c&0x08)a1=graymode;
 228   1       else a1=0;
 229   1       if(c&0x04)a2=graymode;
 230   1       else a2=0;
 231   1       if(c&0x02)a3=graymode;
 232   1       else a3=0;
 233   1       if(c&0x01)a4=graymode;
 234   1       else a4=0;
 235   1      
 236   1       a4=(a1<<6)+(a2<<4)+(a3<<2)+a4;
 237   1      
 238   1       return a4;
 239   1      }
 240          //===========================================
C51 COMPILER V7.09   DGL                                                                   04/15/2008 09:53:26 PAGE 5   

 241          void Display_Char()

⌨️ 快捷键说明

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