我的lcd程序,调试通过的
#include <global.h>
/*rs---------P0.0 经锁存器后
rw---------P0.1
E----------RD和WR与非后,再和P2.6与非后再反相
*/
#define LCDCOM XBYTE[0x4000] //命令寄存器地址cs=1,rs=0,rw=0
#define LCDDATA XBYTE[0x4001] //数据寄存器地址cs=1,rs=1,rw=0
#define LCDREAD XBYTE[0x4002] //读取数据 cs=1,rs=0,rw=1
byte bdata busy;
sbit busy_flag=busy^7; //忙标志
//测试lcd忙
void wait_lcd(void)
{ do
{ busy=LCDREAD;
}
while(busy_flag==1);
}
//送命令字
void I_SEND(byte y)
{
wait_lcd();
LCDCOM=y;
}
//送数据
void D_SEND(byte x)
{ wait_lcd();
LCDDATA=x;
}
//LCD初始化
void start_lcd()
{ delay_ms(50);
I_SEND(0x01); //清屏
I_SEND(0x38);
delay_ms(5);
I_SEND(0x38);
delay_ms(100);
I_SEND(0x38);
delay_100us(1);
I_SEND(0x38);
I_SEND(0x0C);
delay_ms(2);
I_SEND(0x06);
}
发表时间:2003年12月16日12:10:45