12864点阵液晶显示

Posted Treysure

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了12864点阵液晶显示相关的知识,希望对你有一定的参考价值。

1系统12864点阵型液晶显示屏的基本原理

          12864点阵图形液晶显示器应用,一种通过C51编程实现对LCD12864液晶屏的控制,液晶显示器(LCD)具有低工作电压、微功耗、显示灵活、成本低等特点。

       数字电路中数据以0和1保存,对LCD控制器进行不同的数据操作,可以得到不同的结果。对于显示英文操作,由于英文字母种类少只需要8位(一字节)即可。而对于中文,常用却有6000以上,于是我们的DOS前辈想了一个办法,就是将ASCII表的高128个很少用到的数值以两个为一组来表示汉字,即汉字的内码。而剩下的低128位则留给英文字符使用,即英文的内码。

       得到了汉字的内码后,利用文字的字模,即用数字的各位信息来记载英文或汉字的形状,如英文的'A'在字模的记载方式如图1所示:                 

         

而中文的“你”在字模中的记载却如图2所示:

         

2. 汉字图形点阵液晶显示模块(QC12864B)主要技术参数和显示特性:

① QC12864B汉字图形点阵液晶显示模块,可显示汉字及图形

② 内置 8192个中文汉字(16X16点阵)、128个字符(8X16点阵)及 64X256点阵显示 RAMGDRAM

③ 电源:VDD 3.3V~+5V(内置升压电路,无需负压)显示内容:128列× 64   

④ 显示颜色:黄绿屏,蓝屏

⑤ 显示角度:600钟直视

⑥ LCD类型:STN

⑦  MCU接口:8位并口或串行配置 LED背光

⑧ 多种软件功能:光标显示、画面移位、自定义字符、睡眠模式等

3.QC12864B读写操作时序:

模块有并行和串行两种连接方法(时序如下):

一、8 位并行连接时序图

 MPU 写资料到模块如图4所示:


MPU写资料到模块图



①MPU 从模块读出资料如图5所示:


MPU从模块读出资料图

二、串行连接时序图


     

串行数据传送共分三个字节完成:

第一字节:串口控制—格式11111ABC

① A 为数据传送方向控制:H 表示数据从 LCD 到 MCU,L 表示数据从 MCU 到 LCD

② B 为数据类型选择:H 表示数据是显示数据,L 表示数据是控制指令

③ C 固定为 0

第二字节: (并行)8 位数据的高 4 位—格式 DDDD0000

第三字节: (并行)8 位数据的低 4 位—格式 0000DDDD 串行接口时序参数:(测试条件:T=25℃ VDD=5.0V)


4.QC12864B点阵型LCD引脚功能说明:

表1 12864LCD的引脚说明

        

    

管脚号

管脚名称

LEVER

管脚功能描述

1

VSS

0

电源地

2

VDD

+5.0V

电源电压

3

V0

-

液晶显示器驱动电压

4

D/I(RS)

H/L

D/I=“H”,表示DB7∽DB0为显示数据

D/I=“L”,表示DB7∽DB0为显示指令数据

5

R/W

H/L

R/W=“H”,E=“H”数据被读到DB7∽DB0

R/W=“L”,E=“H→L”数据被写到IR或DR

6

E

H/L

R/W=“L”,E信号下降沿锁存DB7∽DB0

R/W=“H”,E=“H”DDRAM数据读到DB7∽DB0

7

DB0-DB7

H/L

数据线

8

CS1

H/L

H:选择芯片(左半屏)信号

9

CS2

H/L

H:选择芯片(右半屏)信号

10

RET

H/L

复位信号,低电平复位

11

VOUT

-10V

LCD驱动负电压

12

LED+

-

LED背光板电源

13

LED-

-

LED背光板电源



说明:12864点阵型液晶 C语言程序(可根据自己意愿设定指定点)

/**********************电子系统设计C51编程************************
*  平台:BST-V51 + Keil U4 + STC89S52
*  名称:本程序驱动12864显示一幅图片(包含英文字符、汉字、图形)
*  日期:很久很久以前
*  晶振:11.0592MHZ
*  说明:电子小玩
*  编写:Sure
******************************************************************/
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint  unsigned int
/*12864端口定义*/
#define LCD_data  P0             //数据口
sbit LCD_RS  =  P1^0;            //寄存器选择输入 
sbit LCD_RW  =  P1^1;            //液晶读/写控制
sbit LCD_EN  =  P2^5;            //液晶使能控制
sbit LCD_PSB =  P1^2;            //串/并方式控制
unsigned char code zhu[]=		//图片代码

{ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x3E,0x03,0xE0,
0xFF,0xFF,0xFF,0x00,0xFE,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xF0,0xFF,0x8F,0xF8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,0xBF,0xE0,0x00,0x00,0xF3,0x00,0x03,0xFF,0xFC,0x7C,0xF9,0xF8,   0xFF,0xBE,0xD9,0xEF,0xBE,0xE0,0x00,0x00,0xF3,0x00,0x1F,0xFF,0xFC,0x7C,0x71,0xF0,    0xFF,0xC1,0xE4,0x83,0xC1,0x80,0x00,0x01,0x7F,0x00,0x3F,0xFF,0xFC,0x1D,0x05,0xE0,  0xFF,0xFF,0xFF,0xFF,0xFC,0x00,0x00,0x03,0x7E,0x00,0xFF,0xFF,0xFC,0x0D,0xFD,0x80,    0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x03,0x7E,0x00,0x7F,0xFF,0xE4,0x07,0xFF,0x00,     0xFF,0xFF,0x7F,0xF0,0x00,0x00,0x00,0x07,0xF8,0x00,0xFF,0xFF,0xE5,0xF9,0xFC,0x00,   0xFF,0xE3,0xAF,0xC0,0x00,0x00,0x07,0xBF,0xF8,0x00,0xFF,0xFF,0xE7,0xFE,0x70,0x00,
0xFF,0xE3,0x9F,0x80,0x00,0x00,0x0E,0x1F,0xF0,0x01,0xFF,0xFF,0xCF,0xFF,0x00,0x00,    0xFF,0xC3,0x8F,0x80,0x00,0x00,0x3E,0x4F,0xF0,0x00,0xFF,0xFC,0x0F,0xFF,0x00,0x00,   0xFF,0xC3,0x8F,0x00,0x00,0x10,0xFE,0x0F,0xE0,0x01,0xFF,0xE0,0x0F,0xFF,0x00,0x00, 0xFF,0x03,0x13,0x80,0x00,0x03,0xFC,0x8F,0xE0,0x01,0xFF,0xFF,0xC7,0xFE,0x00,0x00,
0xFF,0x04,0x12,0x80,0x00,0x00,0x7C,0x0F,0x80,0x03,0xFF,0xFF,0xC5,0xF8,0x00,0x00,  0xFE,0x0C,0x17,0xC0,0x00,0x00,0x00,0x3E,0x00,0x07,0xFF,0xFF,0xC0,0xF0,0x0E,0x00,   0xFE,0x1E,0x67,0x7E,0x30,0x00,0x00,0x08,0x00,0x07,0xFF,0xFF,0xC0,0xF8,0x1F,0x00,    0xFC,0x1C,0x42,0x7F,0x00,0x06,0x00,0x00,0x40,0x0F,0xFF,0xFF,0xC1,0xF8,0x3F,0x80,  0xFE,0x08,0x48,0x7F,0x40,0x01,0x78,0x10,0xC0,0x0F,0xFF,0xFF,0xC1,0xF8,0x7F,0xC0,  0xFE,0x08,0x08,0x7F,0x40,0x01,0x78,0x10,0xC0,0x0F,0xFF,0xFF,0xC1,0xF8,0xFF,0xE0, 0xFE,0x00,0x00,0x7E,0x60,0x00,0x00,0x10,0x80,0x3D,0xBF,0xFF,0xC1,0xF9,0xFF,0xF0,
0xFF,0x00,0x00,0x1C,0xC0,0x00,0x04,0x00,0x00,0x39,0x3F,0xFF,0xC1,0xF9,0xFB,0xF0, 0xFF,0x00,0x00,0x71,0x00,0x00,0x3C,0x00,0x00,0x39,0x3F,0xFA,0x41,0xF9,0xFF,0xF0, 0xFF,0x80,0x00,0x60,0x30,0x01,0xC0,0x00,0x00,0x01,0x1B,0x02,0x41,0xF8,0xFF,0xE0, 0xFF,0xC8,0x00,0x00,0x31,0x1F,0x00,0x00,0x40,0x00,0x00,0x02,0x41,0xF8,0x7F,0xC0, 0xFF,0xC4,0xFE,0x00,0x03,0x00,0x07,0xC7,0xC2,0x00,0x00,0x04,0x01,0xF8,0x3F,0x80, 0xFF,0xFF,0xF0,0x00,0x0F,0xE0,0x3F,0x9C,0x0F,0x80,0x00,0x04,0x01,0xF8,0x1F,0x00,  0xFF,0xFF,0xF8,0x10,0x0F,0xC0,0x7E,0x3F,0xE7,0xFF,0x00,0x00,0x01,0xF8,0x0E,0x00,
0xFF,0xFF,0xF8,0x1E,0x0F,0xE0,0x70,0x3F,0xE0,0x3F,0x00,0x00,0x01,0xF8,0x00,0x00,  0xFF,0xFF,0xFC,0x1E,0x1D,0xE0,0x77,0x00,0xE0,0x00,0x00,0x00,0x01,0xF8,0x00,0x00,  0xFF,0xFF,0xFC,0x03,0x99,0xE0,0xE7,0x36,0xE0,0x00,0x00,0x00,0x03,0xFC,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xC1,0x07,0x60,0xF0,0x10,0x3F,0xFF,0xDB,0xFF,0xFF,0xF0,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x63,0xF4,0x30,0x3F,0xFF,0xDF,0xFF,0xFF,0xF0, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x04,0x70,0x3F,0xFF,0xD7,0xFE,0xFF,0xE0,   0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x01,0xF0,0x3F,0xFF,0xD7,0xFE,0xFF,0xE0,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x40,0x1F,0xF0,0x00,0x3F,0xE7,0xFE,0x00,0x00,    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF1,0x00,0x00,0xE7,0xFE,0x00,0x00,     0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x07,0xFE,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,0x07,0xFE,0x00,0x00
};


#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
void delay0(uchar x);  //x*0.14MS
void  dataconv();
void lcd_pos(uchar X,uchar Y);  //确定显示位置
void delay(int ms)
{   while(ms--)
	{
      uchar i;
	  for(i=0;i<250;i++)  
	   { _nop_();_nop_();_nop_();_nop_();  }   
	}
}		
/*******************************************************************/
/*                                                                 */
/*检查LCD忙状态                                                   */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。      */
/*                                                                 */
/*******************************************************************/
bit lcd_busy()
 {  bit result;
    LCD_RS = 0;
    LCD_RW = 1;
    LCD_EN = 1;
    delayNOP();
    result = (bit)(P0&0x80);
    LCD_EN = 0;
    return(result);                    
 }
/*******************************************************************/
/*写指令数据到LCD                                                 */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。                          */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{                          
   while(lcd_busy());
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 0;
    _nop_();    _nop_(); 
    P0 = cmd;
    delayNOP();
    LCD_EN = 1;
    delayNOP();
    LCD_EN = 0;  
}
/*******************************************************************/
/*                                                                 */
/*写显示数据到LCD                                                */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。                           */
/*                                                                 */
/*******************************************************************/
void lcd_wdat(uchar dat)
{                          
   while(lcd_busy());
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 0;
    P0 = dat;
    delayNOP();
    LCD_EN = 1;
    delayNOP();
    LCD_EN = 0; 
}
/*******************************************************************/
/*                                                                 */
/*  LCD初始化设定                                                */
/*                                                                 */
/*******************************************************************/
void lcd_init()
{
    LCD_PSB = 1;         //并口方式
    lcd_wcmd(0x34);      //扩充指令操作
    delay(5);
    lcd_wcmd(0x30);      //基本指令操作
    delay(5);
    lcd_wcmd(0x0C);      //显示开,关光标
    delay(5);
    lcd_wcmd(0x01);      //清除LCD的显示内容
    delay(5);
}
/*******************************************
函数名称:Draw_PM
功    能:在整个液晶屏幕上画图
参    数:无
返回值  :无
********************************************/
void Draw_PM(const uchar *ptr)
{
    uchar i,j,k;
	lcd_wcmd(0x34);        //打开扩展指令集
	i = 0x80;            
	for(j = 0;j < 32;j++)
	{
        lcd_wcmd(i++);
        lcd_wcmd(0x80);
  		for(k = 0;k < 16;k++)
  		{  lcd_wdat(*ptr++);}
	}
	i = 0x80;
 	for(j = 0;j < 32;j++)
	{   lcd_wcmd(i++);
        lcd_wcmd(0x88);	   
  		for(k = 0;k < 16;k++)
  		{  lcd_wdat(*ptr++);	} 
	}  
    lcd_wcmd(0x36);        //打开绘图显示
	lcd_wcmd(0x30);        //回到基本指令集
}

main()
 {     lcd_init();         //初始化LCD    
   		Draw_PM(zhu);    //显示设定的图片
 		while(1);	
 }

实物图



转载请注明来源,么么哒!原创声明:本文为-Sure-原创作品,转载时请注明“转自-Sure-”及原文链接。