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

📄 ocm4x8c.lst

📁 Keil c工程
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE OCM4X8C
OBJECT MODULE PLACED IN .\out\OCM4X8C.obj
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE c\OCM4X8C.c BROWSE INTVECTOR(0XC000) DEBUG OBJECTEXTEND PRINT
                    -(.\lst\OCM4X8C.lst) OBJECT(.\out\OCM4X8C.obj)

line level    source

   1          
   2          
   3          /*****************  version infermation ******************************/
   4          //
   5          //build on 2004/03/16
   6          //2004/04/09 debug draw picture mode.pass.
   7          //2004/04/14 update function DrawPicture() and revise CGRAM.
   8          //
   9          /******************* hardware connection discreption ************************************/
  10          //ocm4x8c and with character mold lcd(ST7920) compatible provided
  11          //pin1:GND
  12          //pin2:VCC
  13          //pin3:not connected
  14          //pin4:RS(CS) connect to A1
  15          //pin5:RW     connect to A0
  16          //
  17          //!!the follow is important ,please vary the address 0x4000 accord to your hardware!!
  18          // 
  19          //pin6:EN=(!A_LCD)&(!(WRn&RDn)  ;HARDWARE connect:WRn and RDn is 8031 P3.6,P3.7 respectively;
  20          //                              A_LCD is 74138 output Y2n,also as 8031 address of 0x4000
  21          //                              74138 input A connect to 8031 P2.7(A15),B to P2.6(A14),C to P2.5(A13)
  22          //
  23          //pin7:DB0      connect to D0
  24          //...           ...
  25          //pin14:DB7     connect to D7
  26          //pin15:connect to vcc,parallel mode
  27          //pin16:not used
  28          //pin17:RESETn   not used
  29          //pin18:not connected
  30          //pin19:connect to VCC
  31          //pin20:connect to GND
  32          //
  33          //D0-D7 is the data bus,and A0-A15 is the address bus(so you must use a 74373)
  34          //
  35          /**********************************************************************************/
  36          //  NOTE: 必须成对使用半角字符,否则将出错                                                                                //
  37          /**********************************************************************************/
  38          
  39          /****************************函数原型**********************************************
  40          void WaitMode(void);
  41          void OCM4X8C_initial(void);
  42          void IndexShiftLeft(void);
  43          void IndexShiftRight(void);
  44          void WholeShiftLeft(void);
  45          void WholeShiftRight(void);
  46          void ClearLine(byte);
  47          void WholeShiftLeft_Clear(void);
  48          void WholeShiftRight_Clear(void);
  49          void WholeShiftLeft_Roll(void);
  50          void WholeShiftRight_Roll(void);
  51          void SetStartPoisition(byte line,byte x);
  52          void DisplayEChar(byte EChar);
  53          void DisplayCChar(word CChar);
  54          void DisplayString(byte *string);
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 2   

  55          void DeleteNumber(void);
  56          void DisplayNumber(word number);
  57          void DrawPicture(byte *bmpPicture);
  58          
  59          *****************************************************************************/
  60          
  61          #define OCM4X8C         //有字库液晶
  62          
  63          #ifdef OCM4X8C
  64          #include <absacc.h>
  65          //#include <math.h>
  66          #include "..\h\OCM4X8C.h"
  67          
  68          bit CheckOdd;   //初始值为0,输入偶数个字节为0,奇数个字节为1
  69          //byte ShiftLeftNumber=0,ShiftRightNumber=0;
  70          char ShiftNumber=0;     //正值为右移,负值为左移
  71          code byte SelfMadeChar[4][16*2];        //4 16*16 self made characters dot matrix data
  72                  
  73          
  74          bit CheckBusy(void)             //返回值为1,说明正忙
  75          {
  76   1      byte i;
  77   1      if((i=XBYTE[OCM4X8C_READ_INSTRUCTION])>=0x80)return(1);
  78   1      else return(0);
  79   1      }
  80          byte ReadAC(void)               // AC as the ADDRESS COUNTER
  81          {
  82   1      return(XBYTE[OCM4X8C_READ_INSTRUCTION]&0x7F);
  83   1      }
  84          
  85          //
  86          byte OCM4X8C_ReadData(void)       //add on 2004/06/30
  87          {
  88   1              while(CheckBusy());   
  89   1              return(XBYTE[OCM4X8C_READ_DATA]);
  90   1      }
  91          
  92          void OCM4X8C_WriteData(byte data_w)      //add on 2004/06/30
  93          {
  94   1              while(CheckBusy());
  95   1              XBYTE[OCM4X8C_WRITE_DATA]=data_w;   
  96   1      }
  97          
  98          void OCM4X8C_WriteInstruction(byte instr)  //add on 2004/06/30
  99          {
 100   1              while(CheckBusy());
 101   1              XBYTE[OCM4X8C_WRITE_INSTRUCTION]=instr;
 102   1      }
 103          void WaitMode(void)
 104          {
 105   1      OCM4X8C_WriteInstruction(CLEAR_DISPLAY);                //clear all DDRAM(20h),set AC to 00h
 106   1      }
 107          
 108          void SetToBasicOperation(void)          //基本指令集动作
 109          {
 110   1      OCM4X8C_WriteInstruction(SET_FUNCTION_BASIC);
 111   1      }
 112          
 113          void SetToExtendOperation(void)         //扩展指令集动作
 114          {
 115   1      OCM4X8C_WriteInstruction(SET_FUNCTION_EXTEND);
 116   1      }
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 3   

 117          
 118          void OCM4X8C_initial(void)
 119          //if you need the index and index position,add this function.
 120          //note:after draw a picture,index and index position will be set off.
 121          {
 122   1      CheckOdd=0;                     //add on 2004/06/29
 123   1      WaitMode();
 124   1      SetToBasicOperation();
 125   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+7);     //whole display on,index on,index position on
 126   1      OCM4X8C_WriteInstruction(SET_ENTRANCE_POINT+2);//index shift right;whole display no move 
 127   1      }
 128          
 129          
 130          void IndexShiftLeft(void)
 131          //index shift left 16 pixels,but not clear display,it will be replaced by the follow character.
 132          {
 133   1      OCM4X8C_WriteInstruction(0x10);
 134   1      }
 135          
 136          void IndexShiftRight(void)
 137          //index shift right as 16 pixels,left a space
 138          {
 139   1      OCM4X8C_WriteInstruction(0x14);
 140   1      }
 141          
 142          void SetCGRAM(byte index)
 143          //index should be value in 00h to 03h
 144          {
 145   1      byte i;
 146   1      
 147   1      OCM4X8C_WriteInstruction(SET_CGRAM+index*0x10);
 148   1      for(i=0;i<32;i++) 
 149   1              {
 150   2              OCM4X8C_WriteData(SelfMadeChar[index][i]);
 151   2              }
 152   1      
 153   1      }
 154          
 155          
 156          void SetDDRAM(byte AC)          //设置指针AC的位置。
 157          {
 158   1      OCM4X8C_WriteInstruction(SET_DDRAM+AC);
 159   1      }
 160          
 161          void ClearLine(byte line)
 162          //清空第line行
 163          {
 164   1      byte i,AC;
 165   1      
 166   1              AC=ReadAC();
 167   1              switch(line)
 168   1              {
 169   2               case 1:SetDDRAM(0x0);break;
 170   2               case 2:SetDDRAM(0x10);break;
 171   2               case 3:SetDDRAM(0x8);break;
 172   2               case 4:SetDDRAM(0x18);break;
 173   2              }
 174   1              for(i=0;i<16;i++) OCM4X8C_WriteData(' ');
 175   1              SetDDRAM(AC);                   //设置为原来的指针AC
 176   1      }
 177          
 178          void WholeShiftLeft(void)
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 4   

 179          //no change in RAM,but need to vary line.
 180          {
 181   1      OCM4X8C_WriteInstruction(0x18);
 182   1      }
 183          
 184          void WholeShiftRight(void)
 185          {
 186   1      OCM4X8C_WriteInstruction(0x1c);
 187   1      }
 188          
 189          void ClearCChar(byte AC)                //add on 2004/07/02
 190          {
 191   1      SetDDRAM(AC);
 192   1      OCM4X8C_WriteData(0x20);
 193   1      OCM4X8C_WriteData(0x20);
 194   1      
 195   1      }
 196          void WholeShiftLeft_Clear(void)
 197          {
 198   1      ShiftNumber%=8;
 199   1      
 200   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+4);     //whole display on,index off,index position off
 201   1      
 202   1      if(ShiftNumber<=0)
 203   1      {
 204   2              ClearCChar(-ShiftNumber);
 205   2              ClearCChar(0x10-ShiftNumber);
 206   2              ClearCChar(0x8-ShiftNumber);
 207   2              ClearCChar(0x18-ShiftNumber);
 208   2      }
 209   1      else
 210   1      {
 211   2              ClearCChar(0x10-ShiftNumber);
 212   2              ClearCChar(0x20-ShiftNumber);
 213   2              ClearCChar(0x8-ShiftNumber);
 214   2              ClearCChar(0x18-ShiftNumber);
 215   2      
 216   2      }
 217   1      ShiftNumber--;
 218   1      WholeShiftLeft();
 219   1      }
 220          
 221          void Change(byte AC1,byte AC2)
 222          //对换行滚动进行校正,add on 2004/07/02
 223          {
 224   1      byte temp1,temp2,temp3,temp4;
 225   1      
 226   1      SetDDRAM(AC1);
 227   1      temp1=OCM4X8C_ReadData();               //预读,必不可少
 228   1      temp1=OCM4X8C_ReadData();
 229   1      temp2=OCM4X8C_ReadData();
 230   1      
 231   1      SetDDRAM(AC2);
 232   1      temp3=OCM4X8C_ReadData();
 233   1      temp3=OCM4X8C_ReadData();
 234   1      temp4=OCM4X8C_ReadData();
 235   1      
 236   1      SetDDRAM(AC2);
 237   1      OCM4X8C_WriteData(temp1);
 238   1      OCM4X8C_WriteData(temp2);
 239   1      
 240   1      SetDDRAM(AC1);
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 5   

 241   1      OCM4X8C_WriteData(temp3);
 242   1      OCM4X8C_WriteData(temp4);
 243   1      
 244   1      }
 245          
 246          void WholeShiftLeft_Roll(void)
 247          {
 248   1      ShiftNumber%=8;                 //每行8个汉字,实际为16个,分两行。
 249   1      
 250   1      if(ShiftNumber<=0)
 251   1      {
 252   2              Change(-ShiftNumber,0x8-ShiftNumber);
 253   2              Change(0x10-ShiftNumber,0x18-ShiftNumber);
 254   2      }
 255   1      else
 256   1      {
 257   2              Change(0x8-ShiftNumber,0x10-ShiftNumber);
 258   2              Change(0x18-ShiftNumber,0x20-ShiftNumber);
 259   2      }
 260   1      ShiftNumber--;
 261   1      WholeShiftLeft();
 262   1      
 263   1      }
 264          
 265          void WholeShiftRight_Clear(void)
 266          {
 267   1      ShiftNumber%=8;
 268   1      
 269   1      OCM4X8C_WriteInstruction(DISPLAY_STATUS+4);     //whole display on,index off,index position off
 270   1      
 271   1      if(ShiftNumber>=0)
 272   1      {
 273   2              ClearCChar(0x7-ShiftNumber);
 274   2              ClearCChar(0x17-ShiftNumber);
 275   2              ClearCChar(0xf-ShiftNumber);
 276   2              ClearCChar(0x1f-ShiftNumber);
 277   2      }
 278   1      else
 279   1      {
 280   2              ClearCChar(0x7-ShiftNumber);
 281   2              ClearCChar(0x17-ShiftNumber);
 282   2              ClearCChar(-ShiftNumber-1);
 283   2              ClearCChar(0x9-ShiftNumber);
 284   2      }
 285   1      
 286   1      ShiftNumber++;
 287   1      WholeShiftRight();
 288   1      }
 289          
 290          void WholeShiftRight_Roll(void)
 291          {
 292   1      ShiftNumber%=8;
 293   1      
 294   1      if(ShiftNumber>=0)
 295   1      {
 296   2              Change(0x7-ShiftNumber,0xf-ShiftNumber);
 297   2              Change(0x17-ShiftNumber,0x1f-ShiftNumber);
 298   2      }
 299   1      else
 300   1      {
 301   2              Change(0x7-ShiftNumber,-ShiftNumber-1);
 302   2              Change(0x17-ShiftNumber,0x9-ShiftNumber);
C51 COMPILER V7.10   OCM4X8C                                                               08/29/2005 13:01:17 PAGE 6   

 303   2      }
 304   1      
 305   1      ShiftNumber++;
 306   1      WholeShiftRight();
 307   1      
 308   1      }
 309          
 310          
 311          
 312          void BackWhite(byte line)               //扩展指令集动作,line=1--4
 313          {
 314   1      OCM4X8C_WriteInstruction(BACK_WHITE+line-1);
 315   1      }
 316          
 317          void DrawOn(void)                       //扩展指令集动作,绘图显示开
 318          {
 319   1      OCM4X8C_WriteInstruction(DRAW_ON);
 320   1      }
 321          
 322          void DrawOff(void)
 323          {
 324   1      OCM4X8C_WriteInstruction(DRAW_OFF);
 325   1      }
 326          
 327          void DisplayCGRAM(byte index)
 328          //display 4 16*16 self define character
 329          {
 330   1      //index should be valued in 00h to 03h
 331   1              OCM4X8C_WriteData(0);
 332   1              OCM4X8C_WriteData(2*index);
 333   1      }
 334          
 335          void SetStartPoisition(byte line,byte x)
 336          {
 337   1      extern void  DisplayEChar(byte);
 338   1      byte line_real;
 339   1      if(CheckOdd) DisplayEChar(' ');  //add on 2004/06/01
 340   1      
 341   1      switch(line)

⌨️ 快捷键说明

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