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

📄 st7920并行方式.lst

📁 ST7920芯片的并行接口显示程序.下载进51就可以测试12864
💻 LST
字号:
C51 COMPILER V8.02   ST7920并行方式                                                        03/22/2009 04:18:39 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE ST7920并行方式
OBJECT MODULE PLACED IN st7920并行方式.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE st7920并行方式.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          
   2          #include <reg52.h>
   3          
   4          #define uint  unsigned int
   5          #define uchar unsigned char
   6          #define x1    0x80
   7          #define x2    0x88
   8          #define y     0x80
   9          #define comm  0
  10          #define dat   1
  11          
  12          sbit RS = P0^0;   //H=data; L=command;
  13          sbit RW = P0^1;   //H=read; L=write;
  14          sbit  E = P0^2;   //input enable;
  15          sbit PSB= P0^3;   //H=并口; L=串口;
  16          sbit RST= P0^4;   //Reset Signal 低电平有效
  17          
  18          sbit busy=P1^7;   //lcd busy bit
  19          
  20          void wr_lcd (uchar dat_comm,uchar content);
  21          void chk_busy (void);
  22          void delay (uint us);
  23          uchar code logo[]={"****************"
  24                             "      V1.0      "
  25                                             "炮兵自动报靶系统"
  26                                             "****************"};
  27          uchar code menu[]={"请选择雷达型号:"
  28                             " 3.LLP92 4.LLP33"
  29                             ">1.LLP32 2.LLP62"
  30                                             " 5. 激光测距机  "};
  31          uchar code link[]={"雷达型号:      "
  32                             "正在建立        "
  33                             "数据连接        "
  34                                             " 5. 激光测距机  "};
  35          uchar code linkok[]={"雷达型号:LLP33  "
  36                                               "接收  ON        "
  37                                                   "链路连接成功    "
  38                                               "发送  ON        "
  39                                             };
  40          
  41          void init_lcd (void)
  42          {
  43   1              RST = 1;
  44   1              PSB = 1;
  45   1              wr_lcd(comm,0x30);  /*30---基本指令动作*/   
  46   1              wr_lcd(comm,0x01);  /*清屏,地址指针指向00H*/
  47   1              wr_lcd(comm,0x06);  /*光标的移动方向*/
  48   1              wr_lcd(comm,0x0c);  /*开显示,关游标*/
  49   1      }
  50          
  51          /******************************************************************************************
  52          * 函数名称    :chn_disp
  53          * 功能描述    : 显示汉字或字符
  54          **********************************************/
  55          
C51 COMPILER V8.02   ST7920并行方式                                                        03/22/2009 04:18:39 PAGE 2   

  56          void chn_disp(uchar code *chn)
  57          {
  58   1              uchar i,j;
  59   1              wr_lcd(comm,0x30);
  60   1              wr_lcd(comm,0x80);
  61   1              for(j=0;j<4;j++)
  62   1              {
  63   2              for(i=0;i<16;i++)
  64   2              wr_lcd(dat,chn[j*16+i]);
  65   2              }
  66   1      }
  67          
  68          
  69          
  70          /******************************************************************************************
  71          * 函数名称    :lat_disp
  72          * 功能描述    : 显示点阵
  73          ******************************************************************************************/
  74          void lat_disp(uchar data1,uchar data2)
  75          {
  76   1              uchar i,j,k,x;
  77   1              x=x1;
  78   1              for(k=0;k<2;k++)
  79   1              {
  80   2              for(j=0;j<16;j++)
  81   2              {
  82   3              for(i=0;i<8;i++)
  83   3              {
  84   4                      wr_lcd(comm,0x34);
  85   4                      wr_lcd(comm,y+j*2);
  86   4                      wr_lcd(comm,x+i);
  87   4                      wr_lcd(comm,0x30);
  88   4                      wr_lcd(dat,data1);
  89   4                      wr_lcd(dat,data1);
  90   4              }
  91   3              for(i=0;i<8;i++)
  92   3              {
  93   4                      wr_lcd(comm,0x34);
  94   4                      wr_lcd(comm,y+j*2+1);
  95   4                      wr_lcd(comm,x+i);
  96   4                      wr_lcd(comm,0x30);
  97   4                      wr_lcd(dat,data2);
  98   4                      wr_lcd(dat,data2);
  99   4              }
 100   3              }
 101   2              x=x2;
 102   2              }
 103   1              wr_lcd(comm,0x36);
 104   1      }
 105          
 106          /******************************************************************************************
 107          * 函数名称    :con_disp
 108          * 功能描述    : 当data1=0xff,data2=0xff时,在x0,y0处反白显示16xl*yl
 109          ******************************************************************************************/
 110          void con_disp(uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl)
 111          {
 112   1              uchar i,j;
 113   1              for(j=0;j<yl;j++)
 114   1              {
 115   2              for(i=0;i<xl;i++)
 116   2              {
 117   3              wr_lcd(comm,0x34);
C51 COMPILER V8.02   ST7920并行方式                                                        03/22/2009 04:18:39 PAGE 3   

 118   3              wr_lcd(comm,y0+j);
 119   3              wr_lcd(comm,x0+i);
 120   3              wr_lcd(comm,0x30);
 121   3              wr_lcd(dat,data1);
 122   3              wr_lcd(dat,data2);
 123   3              }
 124   2              }
 125   1              wr_lcd(comm,0x36);
 126   1      }
 127          
 128          /******************************************************************************************
 129          * 函数名称    :clrram
 130          * 功能描述    : 清DDRAM
 131          ******************************************************************************************/
 132          void clrram(void)
 133          {
 134   1              wr_lcd(comm,0x30);
 135   1              wr_lcd(comm,0x01);
 136   1      }
 137          
 138          void wr_lcd(uchar dat_comm,uchar content)
 139          {
 140   1              chk_busy ();
 141   1              if(dat_comm)
 142   1              {
 143   2              RS = 1;   //data
 144   2              RW = 0;   //write
 145   2              }
 146   1              else 
 147   1              {
 148   2              RS = 0;   //command
 149   2              RW = 0;   //write
 150   2              }
 151   1              P1=content;   //output data or comm
 152   1              E = 1;
 153   1              ;
 154   1              E = 0;
 155   1      }
 156          void chk_busy(void)
 157          {
 158   1              P1 = 0xff;
 159   1              RS = 0;
 160   1              RW = 1;
 161   1              E = 1;
 162   1              while(busy==1);
 163   1              E = 0;
 164   1      }
 165          
 166          void delay(uint us)   //delay time
 167          {
 168   1              while(us--);
 169   1      }
 170          
 171          
 172          void delay1(uint ms)
 173          {
 174   1              uint i,j;
 175   1              for(i=0;i<ms;i++)
 176   1              for(j=0;j<15;j++)
 177   1              delay(1);
 178   1      }
 179          
C51 COMPILER V8.02   ST7920并行方式                                                        03/22/2009 04:18:39 PAGE 4   

 180          void main()
 181          {
 182   1              SP=0x5f;
 183   1              init_lcd();
 184   1              while(1)
 185   1              {       lat_disp(0xff,0xff);
 186   2                   chn_disp(logo);
 187   2              //con_disp(0xff,0xff,0x8c,0x80,16,64);
 188   2              delay1(8000);
 189   2              lat_disp(0xff,0xff);
 190   2              chn_disp(menu);
 191   2              //con_disp(0xff,0xff,0x8c,0x80,16,64);
 192   2              delay1(8000);
 193   2                  //lat_disp(0x00,0x00);
 194   2              init_lcd();
 195   2              chn_disp(link);
 196   2              //con_disp(0xff,0xff,0x8c,0x80,16,64);
 197   2              delay1(8000);
 198   2                      lat_disp(0x00,0x00);
 199   2              chn_disp(linkok);
 200   2              //con_disp(0xff,0xff,0x8c,0x80,16,64);
 201   2              delay1(8000);
 202   2              
 203   2              
 204   2              }
 205   1      }


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