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

📄 12864字库.lst

📁 带字库的12864显示程序加上打印机打印
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   12864字库                                                             08/10/2007 02:44:31 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE 12864字库
OBJECT MODULE PLACED IN 12864字库.OBJ
COMPILER INVOKED BY: D:\e\Keil\C51\BIN\C51.EXE 12864字库.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*============================================================
   2                  使用12864液晶显示和PS/2键盘的示例     杨川  2007/7/25
   3                  -------------------------------------------------
   4          //==============================================================
   5          
   6          SMC1602A(16*2)模拟口线接线方式
   7          连接线图:       
   8                 ---------------------------------------------------
   9                 |LCM-----51   |  LCM-----51   |  LCM------51      |
  10                 --------------------------------------------------|
  11                 |DB0-----P1.0 |  DB4-----P1.4 |  RW-------P2.1    |
  12                 |DB1-----P1.1 |  DB5-----P1.5 |  RS-------P2.0    |
  13                 |DB2-----P1.2 |  DB6-----P1.6 |  E--------P2.2   |
  14                 |DB3-----P1.3 |  DB7-----P1.7 |  VLCD接1K电阻到GND|
  15                 ---------------------------------------------------
  16          
  17          Keyboard接线
  18                PS/2--------51
  19                1 DATA------P3.4
  20                3 GND
  21                4 VCC
  22                5 CLK-------P3.3 接在51的外部中断,触发方式为低电平
  23          
  24          本程序源码只供学习参考,不得应用于商业用途,如有需要请联系作者。
  25          
  26          [注:AT89x51使用12M或11.0592M晶振,实测使用11.0592M]
  27          [Keil uV2 7.01编译运行通过 程序中没有做键盘数据的奇偶校验]
  28          
  29          =============================================================*/
  30          /*修改 于2007/7/31    13:33
  31           利用键盘输入,实现12864显示功能和利用微型打印机实现实时打印功能
  32           keyboard接线
  33                   打印pdata---------P0
  34                   busy---------P3.0
  35                           STB ---------P3.1
  36          =============================================================*/
  37          //===================================================================================//
  38          
  39          //=======本程序带字库的12864显示程序,使用前须将IO口定义,将程序初始化lcdInit ();====//
  40          //清屏程序为lcdClear();
  41          //调用显示汉字的程序为dispString (uchar X,  Y, unsigned int speed, uchar *msg);======//
  42          
  43          //===================================================================================//
  44          
  45          #include<regx51.h>
  46          //#include      <intrins.h>
  47          //#include      <string.h>
  48          #include "scancodes.h"
  49          
  50          #define uchar unsigned char
  51          #define BUSY_FLAG       P0_7                                            //液晶模块忙标志
  52          //#define       MPU_RESET       P2_1                                    //液晶复位控制
  53          #define MPU_RS_CH       P2_0                                            //寄存器选择输入
  54          #define MPU_RW_CH       P2_1                                            //读写控制
  55          #define MPU_ENABLE      P2_2                                            //使能控制
C51 COMPILER V8.02   12864字库                                                             08/10/2007 02:44:31 PAGE 2   

  56          #define LCD_DATA        P0                                                      //液晶数据口
  57          #define uchar unsigned char
  58          #define Key_Data P3_4 //定义Keyboard引脚
  59          #define Key_CLK  P3_3
  60          #define Printdata P1
  61          #define Printbusy P3_0
  62          #define Printstb P3_1
  63          extern void _nop_  (void);
  64          #include<print.c>
  65          void chaxun(char x);
  66          void pr1616(void);
  67          void lf(void);
  68          void fangda(char n);
  69          void xiahuaxian(char n);
  70          void fanbai(char n);
  71          void init(void);
  72          void pr(char j,char x);
*** WARNING C235 IN LINE 72 OF 12864字库.C: parameter 2: different types
  73          void lcdWriteCommand (uchar Command);
  74          void lcdWriteData (uchar Data);
  75          void delayMs (unsigned int ms);
  76          void checkLcdBusy (void);
  77          void DisplayOneChar(unsigned char X, unsigned char Y, unsigned int,unsigned char ddata1);
  78          void DisplayListChar(uchar X, uchar Y,unsigned int, uchar *DData);
  79          void backspace(void);
  80          void Delay5Ms(void);
  81          void Delay400Ms(void);
  82          void Decode(unsigned char ScanCode);
  83          //void chaxun(char x);
  84          char prindata[30]={' '};
  85          char prnum=0;
  86          unsigned char code Cls[] = {"                "};
  87          static unsigned char IntNum = 0; //中断次数计数
  88          static unsigned char KeyV; //键值
  89          static unsigned char DisNum = 0; //显示用指针
  90          static unsigned char Key_UP=0, Shift = 0;//Key_UP是键松开标识,Shift是Shift键按下标识
  91          static unsigned char BF = 0; //标识是否有字符被收到
  92          char flag=1;//用于标志是否打印
  93          
  94          
  95          
  96          
  97          
  98          //===============================================
  99          void lcdWriteCommand (uchar Command)
 100          {
 101   1              checkLcdBusy();
 102   1              delayMs (2);
 103   1              MPU_RS_CH = 0;
 104   1              MPU_RW_CH = 0;
 105   1              LCD_DATA = Command;
 106   1              MPU_ENABLE = 1;
 107   1              delayMs(1);
 108   1              MPU_ENABLE = 0;
 109   1      }
 110          //========延时====================================
 111          void delayMs (unsigned int ms)
 112          {
 113   1              uchar i;
 114   1              while (--ms)
 115   1              {
 116   2                      for (i = 0; i < 125; i++);
C51 COMPILER V8.02   12864字库                                                             08/10/2007 02:44:31 PAGE 3   

 117   2              }
 118   1      }
 119          //===============================================
 120          void checkLcdBusy (void) 
 121          {   char i=1;
 122   1              while(i--);
 123   1      }
 124          //===============================================
 125          void lcdWriteData (uchar Data)
 126          {
 127   1              checkLcdBusy();
 128   1              delayMs (2);
 129   1              MPU_RS_CH = 1;
 130   1              MPU_RW_CH = 0;
 131   1              LCD_DATA = Data;
 132   1              MPU_ENABLE = 1;
 133   1              delayMs(1);
 134   1              MPU_ENABLE = 0;
 135   1      }
 136          
 137          //===============================================
 138          void DisplayListChar(uchar X,uchar Y, unsigned int speed, uchar *msg)
 139          {
 140   1              if (X ==0x00)
 141   1              {
 142   2                      X = 0x80;
 143   2              }
 144   1              else if (X == 0x01)
 145   1              {
 146   2                      X = 0x90;
 147   2              }
 148   1              else if (X == 0x02)
 149   1              {
 150   2                      X = 0x88;
 151   2              }
 152   1              else if (X == 0x03)
 153   1              {

⌨️ 快捷键说明

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