|
单片机驱动128X64的问题,小弟在线急等!!!
[复制链接]
用单片机驱动128X64显示中文字符,程序编译通过了,不知道什么原因显示不出汉字,麻烦高手指点一下,多谢了
代码如下:
/*****************************************/
/* Copyright (c) 2007 SHF */
/* /* 作 者: SHF */
/*****************************************/
#include "reg51.h"
#include
#define uint unsigned int
#define uchar unsigned char
sbit CSA=P3^0;
sbit CSB=P3^1;
sbit DI=P3^2;
sbit RW=P3^3;
sbit E=P3^4;
sbit LCD=P2;
sbit busy_bit=ACC^7; //lcd state byte bit 7
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
};
/*下面是对液晶屏gxm12864d操作的函数, 128x64点阵,汉字显示,CSA,CSB用来进行左右显示区的选择。*/
void delay(unsigned long time)
{
while(time--);
}
/* 发命令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); //写控制字(00)11000000,设置起始显示行。RW=0 DI=0
lcd_mwc(0x3f); //写控制字(00)00111111,设置显示开关。RW=0 DI=0
}
//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));
}
void main(void)
{
E=1;
lcd_clear();
lcd_init();
lcd_mwc(0xb8); //写控制字(00)10111000,设置起始显示行。RW=0 DI=0
lcd_mwc(0x40); //写控制字(00)01000000,设置起始显示列。RW=0 DI=0
dispm_hz_up(&QING);
}
|
|