📄 lcd_bus.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -