历史上的今天
今天是:2024年11月26日(星期二)
2019年11月26日 | 51单片机控制LCD12864显示汉字
2019-11-26 来源:51hei

程序:
#include
#define DATA_PORT P0
sbit LCD12864_EN = P1^2;
sbit LCD12864_RSET = P1^3;
sbit LCD12864_RS = P1^0;
sbit LCD12864_RW = P1^1;
sbit LCD12864_PSB = P1^6;
void delay(unsigned int xms) //延时//
{
unsigned char i,j;
for(j = 0; j < xms; j++)
{
for(i = 0;i < 110;i++);
}
}
bit LcdBusyCheck(){
bit result;
LCD12864_RS = 0;
LCD12864_RW = 1;
LCD12864_EN = 1;
result = (bit)(DATA_PORT&0x80);
LCD12864_EN = 0;
return result;
}
void WriteCmdToLCD(unsigned char cmd)
{
// while(LcdBusyCheck());
delay(10);
LCD12864_RS = 0;
LCD12864_RW = 0;
LCD12864_EN = 1;
DATA_PORT = cmd;
delay(5);
LCD12864_EN = 0;
delay(5);
LCD12864_EN = 1;
}
void WriteDatToLcd(unsigned char dat)
{
//while(LcdBusyCheck());
delay(10);
LCD12864_RS = 1;
LCD12864_RW = 0;
LCD12864_EN = 1;
DATA_PORT = dat;
delay(5);
LCD12864_EN = 0;
delay(5);
LCD12864_EN = 1;
}
void WriteStrToLcd(unsigned char *str)
{
while(*str != '




