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

📄 display_320_240.lst

📁 在采用 320x240 屏的设计实验箱上运行
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   DISPLAY_320_240                                                       12/07/2007 16:55:37 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE DISPLAY_320_240
OBJECT MODULE PLACED IN display_320_240.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE display_320_240.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <reg52.h>
   2          #include <absacc.h>
   3          #include "display_fun.h"
   4          
   5          #ifndef uchar
   6          #define uchar unsigned char
   7          #endif
   8          
   9          sbit lcd_a0=P3^7;
  10          sbit lcd_cs=P1^3;
  11          sbit lcd_rst=P1^4;
  12          sbit lcd_wr=P3^6;
  13          sbit lcd_rd=P1^2;
  14          
  15          #define AP 0x2a
  16          #define LENGTH 0xfa     //波形区域宽度250
  17          #define WIDTH 0xc8      //波形区域高度200
  18          
  19          uchar code sys[8]={0x30,0x87,0x07,0x27,0x2a,0xef,0x2a,0}; /*P1-P8*/
  20          uchar code scr[10]={0,0,0xef,0x00,0x28,0xef,0x00,0x50,0,0}; /*P1-P10*/
  21          uchar code arr[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
  22          
  23          /***************************************************************
  24          *名称:outcode(uchar code_data)
  25          *描述:向液晶屏输出指令代码
  26          *参数:指令代码
  27          *返回:
  28          ****************************************************************/
  29          void outcode(uchar code_data)//输出指令代码
  30          {
  31   1              lcd_cs=0;
  32   1              lcd_a0=1;
  33   1              lcd_rd=1;lcd_wr=1;
  34   1              P0=code_data;
  35   1              lcd_wr=0;
  36   1              lcd_wr=1;
  37   1              lcd_cs=1;
  38   1      }
  39          /***************************************************************
  40          *名称:outdata(uchar data_data)
  41          *描述:向液晶屏输出指令参数
  42          *参数:指令参数
  43          *返回:
  44          ****************************************************************/
  45          void outdata(uchar data_data)//输出指令参数
  46          {
  47   1              lcd_cs=0;
  48   1              lcd_a0=0;
  49   1              lcd_rd=1;
  50   1              lcd_wr=1;
  51   1              P0=data_data;
  52   1              lcd_wr=0;
  53   1              lcd_wr=1;
  54   1              lcd_cs=1;
  55   1      }
C51 COMPILER V8.02   DISPLAY_320_240                                                       12/07/2007 16:55:37 PAGE 2   

  56          /***************************************************************
  57          *名称:uchar indata(void)
  58          *描述:从液晶屏输入数据
  59          *参数:
  60          *返回:输入数据
  61          ****************************************************************/
  62          uchar indata(void)//输入数据
  63          {
  64   1              uchar data_data;
  65   1              lcd_cs=0;
  66   1              lcd_a0=1;
  67   1              P0=0xff;
  68   1              lcd_wr=1;
  69   1              lcd_rd=0;
  70   1              data_data=P0;
  71   1              lcd_rd=1;
  72   1              lcd_cs=1;
  73   1              return data_data;
  74   1      }
  75          /***************************************************************
  76          *名称:turnoff(void)
  77          *描述:关闭液晶屏
  78          *参数:
  79          *返回:
  80          ****************************************************************/
  81          void turnoff(void)
  82          {
  83   1              outcode(0x58);//off screen
  84   1              outdata(0x00);
  85   1      }
  86          /***************************************************************
  87          *名称:turnon(void)
  88          *描述:开启液晶屏
  89          *参数:
  90          *返回:
  91          ****************************************************************/
  92          void turnon(void)
  93          {
  94   1              outcode(0x59);//on screen
  95   1              outdata(0x55);
  96   1      }
  97          /***************************************************************
  98          *名称:initram(void)
  99          *描述:清屏(3层)
 100          *参数:
 101          *返回:
 102          ****************************************************************/
 103          void initram(void)
 104          {//显示存储器清零
 105   1              unsigned int i;
 106   1              outcode(0x4c);
 107   1              outcode(0x46);
 108   1              outdata(0x00);
 109   1              outdata(0x00);
 110   1              outcode(0x42);//clear screen memory
 111   1              for(i=0;i<0x7800;)//24478,32768,0x7800,0x58e5
 112   1              {
 113   2                      outdata(0x00);
 114   2                      i++;
 115   2              }
 116   1      }
 117          /***************************************************************
C51 COMPILER V8.02   DISPLAY_320_240                                                       12/07/2007 16:55:37 PAGE 3   

 118          *名称:initram_1(void)
 119          *描述:清屏(first1层)
 120          *参数:
 121          *返回:
 122          ****************************************************************/
 123          void initram_1(void)
 124          {//显示存储器清零
 125   1              unsigned int i;
 126   1              outcode(0x4c);
 127   1              outcode(0x46);
 128   1              outdata(0x00);
 129   1              outdata(0x00);
 130   1              outcode(0x42);//clear screen memory
 131   1              for(i=0;i<0x2800;i++)//24478,32768,0x7800,0x58e5
 132   1              {
 133   2                      outdata(0x00);
 134   2              }
 135   1      }
 136          /***************************************************************
 137          *名称:init(void)
 138          *描述:初始化程序
 139          *参数:
 140          *返回:
 141          ****************************************************************/
 142          void init(void)
 143          {
 144   1              int n;
 145   1              outcode(0x40); /*SYSTEM SET 指令代码*/
 146   1              for(n=0;n<8;n++)outdata(sys[n]); /*将参数P1-P8 写入*/
 147   1              outcode(0x44); /*SCROLL 指令代码*/
 148   1              for(n=0;n<10;n++)outdata(scr[n]); /*将参数P1-P10 写入*/
 149   1              outcode(0x5a); /*HDOT SCR——P1 清零复位*/
 150   1              outdata(0);
 151   1              outcode(0x5b); /*OVLAY—*/
 152   1              outdata(0x1c);
 153   1      }
 154          /***************************************************************
 155          *名称:WriteD(uchar x,uchar y)
 156          *描述:在第一层写一个点
 157          *参数:点的坐标位置(x,y)
 158          *返回:
 159          ****************************************************************/
 160          void WriteD(uchar x,uchar y)  //write a dot on the 1nd layer
 161          {
 162   1              unsigned int address;
 163   1              uchar addh,addl;
 164   1              uchar m=0,n;
 165   1              address=0x01f9+x/8+y*AP;
 166   1              addh=address>>8;//addh=address/256;
 167   1              addl=(uchar)address;//addl=address%256;
 168   1              n=x%8;
 169   1              outcode(0x46);
 170   1              outdata(addl);
 171   1              outdata(addh);
 172   1              outcode(0x43);
 173   1              m=indata();
 174   1              m=m|arr[n];
 175   1              outcode(0x46);
 176   1              outdata(addl);
 177   1              outdata(addh);
 178   1              outcode(0x42);
 179   1              outdata(m);
C51 COMPILER V8.02   DISPLAY_320_240                                                       12/07/2007 16:55:37 PAGE 4   

 180   1      }
 181          /***************************************************************
 182          *名称:WriteD2(uchar x,uchar y)
 183          *描述:在第二层写一个点
 184          *参数:点的坐标位置(x,y)
 185          *返回:
 186          ****************************************************************/
 187          void WriteD2(uchar x,uchar y)  //write a dot on the 2nd layer
 188          {
 189   1              unsigned int address;
 190   1              uchar addh,addl;
 191   1              uchar m=0,n=0;
 192   1              address=0x29f9+x/8+y*AP;
 193   1              addh=address>>8;//addh=address/256;
 194   1              addl=(uchar)address;//addl=address%256;
 195   1              outcode(0x46);
 196   1              outdata(addl);
 197   1              outdata(addh);
 198   1              outcode(0x43);
 199   1              m=indata();
 200   1              n=x%8;
 201   1              m=m|arr[n];
 202   1              outcode(0x46);
 203   1              outdata(addl);
 204   1              outdata(addh);
 205   1              outcode(0x42);
 206   1              outdata(m);//m
 207   1      }
 208          /***************************************************************
 209          *名称:Hori(uchar y,uchar space)
 210          *描述:在第二层画水平网格线
 211          *参数:网格的行数、空的点数
 212          *返回:
 213          ****************************************************************/
 214          void Hori(uchar y,uchar space)       //画水平网格线
 215          {
 216   1                uchar i;
 217   1                outcode(0x4c);
 218   1                for(i=space;i<LENGTH;i+=space)WriteD2(i,y);
 219   1      }
 220          /***************************************************************
 221          *名称:Ver(uchar x,uchar space)

⌨️ 快捷键说明

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