lcd_bus.c

来自「1602液晶驱动程序,有两个」· C语言 代码 · 共 68 行

C
68
字号
#include <reg52.h>
#include <absacc.h>

#define uchar unsigned char
#define wr_cmd XBYTE[0Xfffc]
#define rd_cmd XBYTE[0Xfffe]
#define wr_dat XBYTE[0xfffd]

void delay(uchar t)
{
	uchar i;
	for(;t>0;t--)
		for(i=164;i>0;i--);
}

void main()
{
	uchar busy;
	char i;
	delay(10);	//lcd和mcu上电复位
	busy=0x80;
	while(busy & 0x80)
		busy=rd_cmd;	//检测忙标志
	busy=0x80;

	wr_cmd=0x38;	//功能设置

	while(busy & 0x80)
		busy=rd_cmd;	//检测忙标志
	busy=0x80;

	wr_cmd=0x0c;

	while(busy & 0x80)
		busy=rd_cmd;	//检测忙标志
	busy=0x80;

	while(1)
	{
		wr_cmd=0x01;
		while(busy & 0x80)
			busy=rd_cmd;	//检测忙标志
		busy=0x80;
		wr_cmd=0x80 | 0x43;
		while(busy & 0x80)
			busy=rd_cmd;	//检测忙标志
		busy=0x80;
		for(i=0;i<10;i++)
		{
			wr_dat=0x30+i;
			delay(255);
		}
		wr_cmd=0x01;
		while(busy & 0x80)
			busy=rd_cmd;	//检测忙标志
		busy=0x80;
		wr_cmd=0x80|0x03;
		while(busy & 0x80)
			busy=rd_cmd;	//检测忙标志
		busy=0x80;
		for(i=9;i>=0;i--)
		{
			wr_dat=0x30+i;
			delay(255);
		}		
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?