gy1206e6.lst

来自「STN ST7920 TEST CODE AND SPEC.」· LST 代码 · 共 343 行

LST
343
字号
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 1   


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

line level    source

   1          // ST7920 128*64 2003.3.25 
   2          #include <reg52.h>
   3          #include <delay.c>
   4          #include <intrins.h>
   5          
   6          #define Uchar unsigned char
   7          //#define Updat  up dat
   8          //#define Dndat  down dat
   9          #define true 1
  10          #define false 0
  11          
  12          sbit CS=P3^1;
  13          sbit SID=P1^7;
  14          sbit SCLK=P1^6;
  15          sbit RES=P3^7;
  16          
  17          void SendMode( Uchar );
  18          void SendCom( Uchar );
  19          void SendData( Uchar );
  20          void Initial(void);
  21          void Disp( Uchar, Uchar ); 
  22          void DispChar( Uchar, Uchar );
  23          //void DispBmp(Uchar *); 
  24          void DispRow( Uchar, Uchar );
  25          
  26          Uchar c1=0xb0;
  27          Uchar c2=0xa0; 
  28          
  29          Uchar Com_mode  = 0xf8;
  30          Uchar Data_mode = 0xfa;
  31          bit   Command_mode = true;
  32          //extern char code w[]; 
  33                                                                                     
  34          void main(void)
  35           {
  36   1         SCLK = 0;
  37   1         Initial();
  38   1        
  39   1         while(1)
  40   1         { 
  41   2           
  42   2           SendCom(0x01);  //DDRAM clear
  43   2           delay(20);   
  44   2           DispRow(0x0ff,0);
  45   2           DispRow(0x00,0x0ff);
  46   2           Disp(0xaa,0xaa);
  47   2           Disp(0x55,0x55);
  48   2           DispRow(0xaa,0x55);
  49   2           DispRow(0x55,0xaa);
  50   2           Disp(0x00,0x00);
  51   2           
  52   2           DispChar(c1,c2);   
  53   2      
  54   2           DispChar(0xc0,0xbc);
  55   2           DispChar(0xb7,0xe6);
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 2   

  56   2           DispChar(0xc3,0xf7);
  57   2          
  58   2         }
  59   1      
  60   1      }
  61          /* 
  62          void DispBmp(Uchar *p)
  63          {
  64             Uchar HorAdd=0x80;
  65             Uchar VerAdd=0x80;
  66             SendCom(0x04);    // I/D =0
  67               for(;VerAdd<0x80+32;VerAdd++)
  68             { 
  69                SendCom(0x34);    // RE=1;
  70                SendCom(0x36);    // Graphics=1;
  71          
  72                SendCom(VerAdd);
  73                SendCom(0x80);
  74                SendCom(0x32);    // RE=0;                       
  75              
  76                for(HorAdd = 0; HorAdd <0x0f; HorAdd++) {SendCom(*p++);SendCom(*p++);}//{SendCom(Updat);SendCom(Dnda
             -t);}
  77             } 
  78          
  79             delay(10000);
  80             SendCom(0x30);    // RE=0;
  81          
  82           }
  83          */
  84          void Disp(Uchar dot1,Uchar dot2)
  85           {
  86   1        Uchar HorAdd=0x80;
  87   1        Uchar VerAdd=0x80;
  88   1      
  89   1        for(;VerAdd<0x80+32;VerAdd++)
  90   1         { 
  91   2            SendCom(0x34);    // RE=1;
  92   2            SendCom(0x36);    // Graphics=1;
  93   2      
  94   2            SendCom(VerAdd);
  95   2            SendCom(0x80);
  96   2            SendCom(0x32);    // RE=0;
  97   2         
  98   2            for(HorAdd = 0; HorAdd <0x0f; HorAdd++)
  99   2              {
 100   3              SendData(dot1); SendData(dot1);
 101   3              SendData(dot2); SendData(dot2);
 102   3              }
 103   2         } 
 104   1      
 105   1         delay(5000);
 106   1      
 107   1         SendCom(0x30);    // RE=0;
 108   1      }
 109          void DispRow(Uchar dot1,Uchar dot2)
 110           {
 111   1       Uchar HorAdd=0x80;
 112   1       Uchar VerAdd=0x80;
 113   1       Uchar Temp=0;
 114   1       bit flag=1;
 115   1      
 116   1        for(;VerAdd<0x80+32;VerAdd++)
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 3   

 117   1         { 
 118   2            SendCom(0x34);    // RE=1;
 119   2            SendCom(0x36);    // Graphics=1;
 120   2      
 121   2            SendCom(VerAdd);
 122   2            SendCom(0x80);
 123   2            SendCom(0x32);    // RE=0;
 124   2           
 125   2           if (flag==1)
 126   2           { 
 127   3             Temp = dot1;
 128   3             flag=0;
 129   3           }
 130   2           else 
 131   2           {
 132   3             Temp = dot2;
 133   3             flag=1;
 134   3           }
 135   2            for(HorAdd = 0; HorAdd <0x0f; HorAdd++)
 136   2              {
 137   3      
 138   3              SendData(Temp);SendData(Temp);
 139   3              SendData(Temp);SendData(Temp);
 140   3      
 141   3              }
 142   2         } 
 143   1      
 144   1         delay(5000);
 145   1         SendCom(0x30);    // RE=0;
 146   1       } 
 147          void DispChar(Uchar Updat,Uchar Dndat) 
 148           {                   
 149   1         Uchar cnt=0;
 150   1         SendCom(0x04);    // I/D =0
 151   1      //   SendCom(0x02);
 152   1         SendCom(0x9f);     // SET DDRAM  00  TO AC 
 153   1         for(c1++,cnt=0;c1<0xf7,cnt<32;cnt++) 
 154   1         {SendData(c1);SendData(c2++);}
 155   1         {SendCom(Updat);SendCom(Dndat);}
 156   1         delay(5000);
 157   1       } 
 158          
 159          void Initial()
 160          {  
 161   1        delay(500);
 162   1        RES  =0;
 163   1        delay(100);
 164   1        RES  =1;
 165   1        delay(100);
 166   1      
 167   1        SendCom(0x30);        //Function set  00 1 DL : x RE G 0       
 168   1         
 169   1        SendCom(0x0c);    // 0000 : 1 D C B ;display on
 170   1        
 171   1        SendCom(0x34);  // RE=1  Function set
 172   1        
 173   1        SendCom(0x0c);        // sleep mode off 
 174   1        SendCom(0x02);        // enable CGRAM          
 175   1      
 176   1        SendCom(0x30);  // RE =0;Function set
 177   1      
 178   1        delay(150);   
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 4   

 179   1                
 180   1       }
 181            
 182          
 183          void SendCom(Uchar dat)
 184          {
 185   1       Uchar cnt = 4;
 186   1      
 187   1       if( !Command_mode )
 188   1          {
 189   2               SendMode(Com_mode);
 190   2           Command_mode = true;
 191   2              }
 192   1       SendMode(Com_mode);
 193   1       while(cnt--)   // Higher  4 bit data
 194   1       {
 195   2               SID  = (bit)( 0x80 & dat );
 196   2               _nop_();
 197   2               SCLK = 1;
 198   2           _nop_();
 199   2               SCLK = 0;
 200   2               dat<<=1;
 201   2       }
 202   1       cnt = 4;
 203   1       while(cnt--)    // fill with 0
 204   1       {
 205   2               SID  = 0;
 206   2               _nop_();
 207   2               SCLK = 1;
 208   2           _nop_();
 209   2               SCLK = 0;
 210   2          _nop_();
 211   2       }
 212   1       delay(0);
 213   1       cnt = 4;
 214   1       while(cnt--)   // Lower 4 bit   data
 215   1       {
 216   2               SID  = (bit)( 0x80 & dat );
 217   2               _nop_();
 218   2               SCLK = 1;
 219   2           _nop_();
 220   2               SCLK = 0;
 221   2               dat<<=1;
 222   2       } 
 223   1       cnt = 4;
 224   1       while(cnt--)   // fill with 0
 225   1       {
 226   2               SID  = 0;
 227   2               _nop_();
 228   2               SCLK = 1;
 229   2           _nop_();
 230   2               SCLK = 0;
 231   2               _nop_();
 232   2       }
 233   1       delay(0);
 234   1      }
 235          
 236          
 237          void SendData(Uchar dat)
 238          {
 239   1       Uchar cnt = 4;
 240   1       
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 5   

 241   1       if( Command_mode )
 242   1       {
 243   2        SendMode(Data_mode);
 244   2        Command_mode = false;
 245   2       }
 246   1       SendMode(Data_mode);
 247   1       while(cnt--)   // Higher  4 bit data
 248   1       {
 249   2               SID  = (bit)( 0x80 & dat );
 250   2               _nop_();
 251   2               SCLK = 1;
 252   2           _nop_();
 253   2               SCLK = 0;
 254   2               dat<<=1;
 255   2       }
 256   1       cnt = 4;
 257   1       while(cnt--)    // fill with 0
 258   1       {
 259   2               SID  = 0;
 260   2               _nop_();
 261   2               SCLK = 1;
 262   2           _nop_();
 263   2               SCLK = 0;
 264   2               _nop_();
 265   2       }
 266   1       delay(0);
 267   1       cnt = 4;
 268   1       while(cnt--)   // Lower 4 bit   data
 269   1       {
 270   2               SID  = (bit)( 0x80 & dat );
 271   2               _nop_();
 272   2               SCLK = 1;
 273   2           _nop_();
 274   2               SCLK = 0;
 275   2               dat<<=1;
 276   2       } 
 277   1       cnt = 4;
 278   1       while(cnt--)   // fill with 0
 279   1       {
 280   2               SID  = 0;
 281   2               _nop_();
 282   2               SCLK = 1;
 283   2           _nop_();
 284   2               SCLK = 0;
 285   2               _nop_();
 286   2       }
 287   1       delay(0);
 288   1      }
 289          
 290          
 291          void SendMode(Uchar com)
 292          {
 293   1       Uchar cnt = 8;
 294   1       CS = 0;
 295   1       _nop_();
 296   1       CS = 1;
 297   1       delay(0);
 298   1       while(cnt--)   // Higher  4 bit data
 299   1       {
 300   2               SID  = (bit)( 0x80 & com );
 301   2               _nop_();
 302   2               SCLK = 1;
C51 COMPILER V7.20   GY1206E6                                                              10/09/2004 09:23:04 PAGE 6   

 303   2           _nop_();
 304   2               SCLK = 0;
 305   2               com<<=1;
 306   2       }
 307   1       delay(0);      
 308   1      }                    


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    744    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      4      16
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1       1
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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