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

📄 128.lst

📁 keilc51环境下12864液晶显示
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   128                                                                   11/21/2007 13:34:35 PAGE 1   


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

stmt level    source

   1          /********************************************************
   2                                  lcd12864
   3                          作者:张建江
   4                          编写时间:2006年1月10日
   5                          最后修改:2006年1月10日
   6                          代码是否优化:否
   7                          
   8          ********************************************************/
   9          #include <reg51.h>
  10          #define uchar unsigned char
  11          //定义通信端口
  12          sbit DQ =P2^0;//ds1820
  13          sbit clock_clk=P1^0;//ds1302_clk
  14          sbit clock_dat=P1^1;//ds1302_dat
  15          sbit clock_rst=P1^2;//ds1302_rst
  16          //lcd控制口
  17          sbit cs2=P2^7;
  18          sbit cs1=P2^6;
  19          sbit rst=P2^5;
  20          sbit rw=P2^3;
  21          sbit di=P2^4;
  22          sbit e=P2^2;
  23          sbit display=P3^2;
  24          sbit dis=P1^3;
  25          //为了编程方便定义的位变量
  26          sbit a0=ACC^0;
  27          sbit a1=ACC^1;
  28          sbit a2=ACC^2;
  29          sbit a3=ACC^3;
  30          sbit a4=ACC^4;
  31          sbit a5=ACC^5;
  32          sbit a6=ACC^6;
  33          sbit a7=ACC^7;
  34          
  35          unsigned char x,y;
  36          unsigned char *p[];
  37          bit m=1;//闪烁指示位
  38          
  39          unsigned char rec[7];//接收控制字缓冲
  40          unsigned char num=0;//控制字序号
  41          //汉字库及数字符号库
  42          unsigned char code dang[32]={0x00,0x00,0x40,0x42,0x5C,0x48,0x40,0x40,0x7F,0x40,0x50,0x4E,0x44,0xC0,0x00,0x
             -00,
  43          0x00,0x00,0x20,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x7F,0x00,0x00};//当
  44          unsigned char code qian[32]={0x08,0x08,0xE8,0xA8,0xA9,0xAE,0xEA,0x08,0x08,0xC8,0x0C,0x0B,0xEA,0x08,0x08,0x
             -00,
  45          0x00,0x00,0x7F,0x04,0x24,0x44,0x3F,0x00,0x00,0x1F,0x40,0x80,0x7F,0x00,0x00,0x00};//前
  46          unsigned char code shi[32]={0x00,0x10,0x2C,0x24,0xA4,0x64,0x25,0x26,0x24,0x24,0xA4,0x24,0x34,0x2C,0x04,0x0
             -0,
  47          0x40,0x40,0x48,0x49,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x4B,0x48,0x40,0x40,0x00};//室
  48          unsigned char code wen[32]={0x10,0x21,0x86,0x70,0x00,0x7E,0x4A,0x4A,0x4A,0x4A,0x4A,0x7E,0x00,0x00,0x00,0x0
             -0,
  49          0x02,0xFE,0x01,0x40,0x7F,0x41,0x41,0x7F,0x41,0x41,0x7F,0x41,0x41,0x7F,0x40,0x00};//温
  50          unsigned char code zero[16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x
             -00};//0
C51 COMPILER V7.06   128                                                                   11/21/2007 13:34:35 PAGE 2   

  51          unsigned char code one[16]={0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x0
             -0};//1
  52          unsigned char code two[16]={0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x0
             -0};//2
  53          unsigned char code three[16]={0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0
             -x00};//3
  54          unsigned char code four[16]={0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x
             -00};//4
  55          unsigned char code five[16]={0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x
             -00};//5
  56          unsigned char code six[16]={0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x0
             -0};//6
  57          unsigned char code seven[16]={0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0
             -x00};//7
  58          unsigned char code eight[16]={0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0
             -x00};//8
  59          unsigned char code nine[16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x
             -00};//9
  60          unsigned char code point[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0
             -x00};//小数点
  61          unsigned char code maohao[16]={0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,
             -0x00};//冒号
  62          unsigned char code tang[32]={0x00,0x00,0x00,0xFC,0x44,0x54,0x54,0x54,0x55,0xFE,0x54,0x54,0xF4,0x44,0x44,0x
             -00,
  63          0x00,0x40,0x30,0x0F,0x00,0x7D,0x25,0x25,0x25,0x27,0x25,0x25,0x7D,0x00,0x00,0x00};//唐
  64          unsigned char code wen1[32]={0x08,0x08,0x08,0x08,0x78,0x88,0x09,0x0E,0x08,0x88,0x78,0x08,0x08,0x08,0x08,0x
             -00,
  65          0x40,0x40,0x40,0x20,0x20,0x11,0x0A,0x04,0x0A,0x11,0x10,0x20,0x60,0x20,0x20,0x00};//文
  66          unsigned char code tao[32]={0x00,0x24,0x24,0xFF,0x24,0x24,0x00,0x94,0xA4,0x4C,0x12,0x82,0xA2,0x98,0x00,0x0
             -0,
  67          0x01,0x01,0x01,0xFF,0x11,0x1F,0x00,0xFF,0x44,0x44,0x40,0x44,0x44,0xFF,0x00,0x00};//韬
  68          unsigned char code nian[32]={0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x
             -00,
  69          0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00};//年
  70          unsigned char code yue[32]={0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x0
             -0,
  71          0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00};//月
  72          unsigned char code xing[32]={0x00,0x00,0x00,0xBE,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x
             -00,
  73          0x00,0x48,0x46,0x41,0x49,0x49,0x49,0x7F,0x49,0x49,0x49,0x49,0x49,0x41,0x40,0x00};//星
  74          unsigned char code qi[32]={0x00,0x04,0xFF,0x54,0x54,0x54,0xFF,0x04,0x00,0xFE,0x22,0x22,0x22,0xFE,0x00,0x00
             -,
  75          0x42,0x22,0x1B,0x02,0x02,0x0A,0x33,0x62,0x18,0x07,0x02,0x22,0x42,0x3F,0x00,0x00};//期
  76          unsigned char code cone[32]={0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xC0,0x80,0x
             -00,
  77          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//一
  78          unsigned char code ctwo[32]={0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x04,0x00,0x00,0x
             -00,
  79          0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x18,0x10,0x00};//二
  80          unsigned char code cthree[32]={0x00,0x04,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x84,0x04,0x00,
             -0x00,
  81          0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00};//三
  82          unsigned char code cfour[32]={0x00,0xFE,0x02,0x02,0x02,0xFE,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0xFE,0x00,0
             -x00,
  83          0x00,0x7F,0x28,0x24,0x23,0x20,0x20,0x20,0x21,0x22,0x22,0x22,0x22,0x7F,0x00,0x00};//四
  84          unsigned char code cfive[32]={0x00,0x02,0x82,0x82,0x82,0x82,0xFE,0x82,0x82,0x82,0xC2,0x82,0x02,0x00,0x00,0
             -x00,
  85          0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x30,0x20,0x00};//五
  86          unsigned char code csix[32]={0x10,0x10,0x10,0x10,0x10,0x91,0x12,0x1E,0x94,0x10,0x10,0x10,0x10,0x10,0x10,0x
             -00,
  87          0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x00,0x00,0x01,0x02,0x0C,0x78,0x30,0x00,0x00};//六
  88          unsigned char code ri[32]={0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00
C51 COMPILER V7.06   128                                                                   11/21/2007 13:34:35 PAGE 3   

             -,
  89          0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00};//日
  90          unsigned char code sheshidu[32]={0x00,0x02,0x05,0xE2,0x18,0x04,0x02,0x02,0x02,0x02,0x02,0x02,0x04,0x1E,0x0
             -0,0x00,
  91          0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x18,0x00,0x00};//摄氏度的符号
  92          
  93          void delay(int num)//延时函数
  94          {
  95   1              while(num--) ;
  96   1      }
  97          
  98          void lw(unsigned char x,unsigned char y,unsigned char dd)//液晶显示器驱动函数 
  99          {
 100   1              if (x<64) 
 101   1              {
 102   2                      cs1=cs2=0;
 103   2                      di=rw=0;cs1=1;cs2=0;P0=0xb8|y;e=1;delay(2);e=0;delay(2);
 104   2                      di=rw=0;cs1=1;cs2=0;P0=0x40|x;e=1;delay(2);e=0;delay(2);
 105   2                      di=1;rw=0;cs1=1;cs2=0;P0=dd;e=1;delay(2);e=0;delay(2);  
 106   2              }
 107   1              else 
 108   1              {
 109   2                      cs1=cs2=0;x=x-64;
 110   2                      di=rw=0;cs1=0;cs2=1;P0=0xb8|y;e=1;delay(2);e=0;delay(2);                        
 111   2                      di=rw=0;cs1=0;cs2=1;P0=0x40|x;e=1;delay(2);e=0;delay(2);
 112   2                      di=1;rw=0;cs1=0;cs2=1;
 113   2              P0=dd;e=1;delay(2);e=0;delay(2);
 114   2                      cs1=cs2=1;
 115   2              }
 116   1              P0=0xff;
 117   1      }
 118          
 119          void lcd_init(void)//lcd初始化
 120          {
 121   1              unsigned char x,y;
 122   1              rst=0;
 123   1              rst=1;  
 124   1              e=di=rw=0;
 125   1              cs1=cs2=1;
 126   1              cs1=0;cs2=1;
 127   1              di=rw=0;P0=0x3f;e=1;delay(2);e=0;delay(2);
 128   1              cs1=0;cs2=1;
 129   1              di=rw=0;P0=0xc0;e=1;delay(2);e=0;delay(2);
 130   1              cs1=cs2=0;
 131   1              cs1=1;cs2=0;
 132   1              di=rw=0;P0=0x3f;e=1;delay(2);e=0;delay(2);
 133   1              cs1=1;cs2=0;
 134   1              di=rw=0;P0=0xc0;e=1;delay(2);e=0;delay(2);
 135   1              cs1=cs2=0;
 136   1          for (y=0;y<8;y++)
 137   1          {
 138   2                      for (x=0;x<128;x++) lw(x,y,0); 
 139   2              }
 140   1      }
 141          
 142          void write_chinese(x,y,array)//向x,y处写入一个汉字
 143          unsigned char x,y;
 144          unsigned char array[];
 145          {
 146   1              unsigned char j,dd;                     
 147   1              for(j=0;j<32;j++)
 148   1              {
C51 COMPILER V7.06   128                                                                   11/21/2007 13:34:35 PAGE 4   

 149   2                      dd=array[j];
 150   2                      if(j<16) lw(x+j,y,dd);
 151   2                       else  lw(x+j-16,y+1,dd);
 152   2              }       
 153   1      }
 154          
 155          void write_flashcn(x,y,array)//向x,y处写入一个汉字,再次写入时取反,需要与变量m配合,构成闪烁效果
 156          unsigned char x,y;
 157          unsigned char array[];
 158          {
 159   1              unsigned char j,dd;                     
 160   1              for(j=0;j<32;j++)
 161   1              {
 162   2                      if(m==1)
 163   2                      dd=array[j];
 164   2                      else
 165   2                      dd=~array[j];
 166   2                      if(j<16) 
 167   2                              lw(x+j,y,dd);
 168   2                      else
 169   2                              lw(x+j-16,y+1,dd);
 170   2              }       
 171   1      }
 172          
 173          void write_digit(x,y,array)//向x,y处写入一个阿拉伯数字
 174          unsigned char x,y;
 175          unsigned char array[];
 176          {
 177   1              unsigned char j,dd;                     
 178   1              for(j=0;j<16;j++)
 179   1              {
 180   2                      dd=array[j];
 181   2                      if(j<8)
 182   2                              lw(x+j,y,dd);
 183   2                      else
 184   2                              lw(x+j-8,y+1,dd);
 185   2              }       
 186   1      }
 187          
 188          
 189          Init_DS18B20(void)//初始化ds1820
 190          {
 191   1              unsigned char x=0;
 192   1              DQ = 1;    //DQ复位
 193   1              delay(8);  //稍做延时
 194   1              DQ = 0;    //单片机将DQ拉低
 195   1              delay(80); //精确延时 大于 480us
 196   1              DQ = 1;    //拉高总线
 197   1              delay(14);
 198   1              x=DQ;      //稍做延时后 如果x=0则初始化成功 x=1则初始化失败
 199   1              delay(20);
 200   1      }
 201          
 202          
 203          ReadOneChar(void)//读一个字节
 204          {
 205   1              unsigned char i=0;
 206   1              unsigned char dat = 0;
 207   1              for (i=8;i>0;i--)
 208   1              {
 209   2                      DQ = 0; // 给脉冲信号
 210   2                      dat>>=1;
C51 COMPILER V7.06   128                                                                   11/21/2007 13:34:35 PAGE 5   

 211   2                      DQ = 1; // 给脉冲信号
 212   2                      if(DQ)
 213   2                      dat|=0x80;
 214   2                      delay(4);
 215   2              }
 216   1              return(dat);
 217   1      }
 218          
 219          
 220          WriteOneChar(unsigned char dat)//写一个字节
 221          {
 222   1              unsigned char i=0;
 223   1              for (i=8; i>0; i--)
 224   1              {
 225   2                      DQ = 0;
 226   2                      DQ = dat&0x01;

⌨️ 快捷键说明

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