单片机实现液晶显示
主要器件:
1、AT89C52作为液晶显示的控制芯片。
2、选用内含KS0108B/HD61202控制器的图形液晶显示模块CXM12864,实现128点*64点大小的平板显示,可以满足一般的显示要求。
3、双电压输出升压芯片MAX1677专用LCD电源芯片。
试验电路图:
试验程序代码:
//lcd_show.h程序
#ifndef_LCD_SHOW_H//防止lcd_show.h被重复引用
#define_LCD_SHOW_H
#include at89c51.h>
#include
unsigned char code QING[32]={
/*请*/
0x20,0x22,0xEC,0x00,0x20,0x22,0xAA,0xAA,
0xAA,0xBF,0xAA,0xAA,0xEB,0xA2,0x20,0x00,
0x00,0x00,0x7F,0x20,0x10,0x00,0xFF,0x0A,
0x0A,0x0A,0x4A,0x8A,0x7F,0x00,0x00,0x00
};
unsigned char code CHA[32]={
/*插*/
0x10,0x10,0x10,0xFF,0x90,0x24,0x24,0xA4,
0x24,0xFC,0x22,0x23,0x22,0xB0,0x20,0x00,
0x02,0x42,0x81,0x7F,0x00,0xFF,0x49,0x48,
0x40,0x7F,0x40,0x49,0x49,0xFF,0x01,0x00
};
unsigned char code KA[32]={
/*卡*/
0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x44,
0x44,0x44,0x46,0x44,0x40,0x60,0x40,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,
0x02,0x04,0x0C,0x18,0x00,0x00,0x00,0x00
};
#define LCD XBYTE[0xffff] /* LCD端口*/
#endif
//lcd_show.c程序实现显示“请插卡”
#include "lcd_show.h"
#define uint unsigned int
#define uchar unsigned char
#define CSA P2^1
#define CSB P2^0
#define E P2^3
#define RW P2^5
#define DI P2^6
sbit busy_bit=ACC^7;//lcd state byte bit 7
/*下面是对液晶屏gxm12864d操作的函数, 128x64点阵,汉字显示,CSA,CSB用来进行左右显示区的选择。*/
/*发命令i到主窗口*/
void lcd_mwc(uchar i)
{
CSA=1;
CSB=0;
RW=1;
DI=0;
do {ACC=LCD;}
while (busy_bit) ;//wait for lcd not busy
RW=0;
LCD=i;
}
/*写数据i到主窗口*/
void lcd_mwd(uchar i)
{
CSA=1;
CSB=0;
RW=1;
DI=0;
do {ACC=LCD;} while (busy_bit);//wait for lcd not busy
RW=0;
DI=1;
LCD=i;
}
/*清屏*/
void lcd_clear(void)
{
uchar i;
uchar page;
for (page=0xb8;page<0xc0;page++)
{
lcd_mwc(page);/*设置显示页面*/
lcd_mwc(0x40);/*设置列地址*/
for (i=0;i<64;i++)
{
lcd_mwd(0);
}
}
}
//初始化lcd
void lcd_init(void)
{
lcd_mwc(0xc0);
lcd_mwc(0x3f);
}
//dispm_hz_up() display up half of a hanzi in left area
void dispm_hz_up(uchar code * hz)
{
uchar i;
for (i=0;i<16;i++) lcd_mwd(*(hz+i));
}
//dispm_hz_down() display down half of a hanzi in left area
void dispm_hz_down(uchar code * hz)
{
uchar i;
for (i=16;i<32;i++) lcd_mwd(*(hz+i));
}
void main(void)
{
E=1;
lcd_clear();
lcd_init();
lcd_mwc(0xb8);
lcd_mwc(0x40);
dispm_hz_up(&QING);
dispm_hz_up(&CHA);
dispm_hz_up(&KA);
lcd_mwc(0xb9);
lcd_mwc(0x40);
dispm_hz_down(&QING);
dispm_hz_down(&CHA);
dispm_hz_down(&KA);//display "请插卡"
}
单片机液晶显 相关文章:
- AT89C51单片机驱动128x64液晶显示C语言(11-30)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)