原创
ST7920汉字点阵LCD的接口程序(直接接方式)
//总线扩展方式连接12832点阵汉字液晶
//A0--D/I
//A1--R/W
//E连接地址分配的0xD000
#include <absacc.h>
#include <REG52.H>
#define CW_Addr XBYTE[0xD000]
#define CR_Addr XBYTE[0xD002]
#define DW_Addr XBYTE[0xD001]
#define DR_Addr XBYTE[0xD003]
unsigned char DisBuf1[17];
unsigned char DisBuf2[17];
void InitLCD()
{
//wait for 40mS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x30; //Function Set: 8bit MPU interface,基本指令集
//wait for 100uS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x30; //Function Set: 8bit MPU interface,基本指令集
//wait for 37uS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x0C; //显示状态:整体显示ON,光标OFF,光标反白OFF
//wait for 100us
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x01; //清屏
//wait for 10mS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x06; //进入点设定:光标右移,AC+1
}
void ReInitLCD()
{
//wait for 40mS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x30; //Function Set: 8bit MPU interface,基本指令集
//wait for 100uS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x30; //Function Set: 8bit MPU interface,基本指令集
//wait for 37uS
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x0F; //显示状态:整体显示ON,光标ON,光标反白ON
//wait for 100us
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x06; //进入点设定:光标右移,AC+1
}
void DisplayBuff0()
{
unsigned char i;
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x80;
for(i=0;i<16;i++)
{
while(CR_Addr & 0x80); //等待BF忙标志
DW_Addr = DisBuf1;
}
}
void DisplayBuff1()
{
unsigned char i;
while(CR_Addr & 0x80); //等待BF忙标志
CW_Addr = 0x90;
for(i=0;i<16;i++)
{
while(CR_Addr & 0x80); //等待BF忙标志
DW_Addr = DisBuf2;
}
}
主程序调用示例
sprintf(DisBuf1,"一二三四技术公司");
sprintf(DisBuf2,"系统自检中 ");
DisplayBuff0();
DisplayBuff1();
sprintf(DisBuf1,"体积总量: m3");
sprintf(DisBuf2," %12.3f ",massflow); //体积总量
DisplayBuff0();
DisplayBuff1();
文章评论(0条评论)
登录后参与讨论