把主頻降到幾兆試試。一般來說,有讀忙操作,是否延時影響不太大,可能是IO配置或初始化指令操作有誤。下面是以前寫的測試可用的(51,晶振12M,8線),你試下。#include<reg51.h>
#define BF P1_7
#define RS P2_0
#define RW P2_1
#define E P2_2
#define IO P1
sbit P1_7=P1^7;
sbit P2_0=P2^0;
sbit P2_1=P2^1;
sbit P2_2=P2^2;
/*****忙標志*******/
unsigned char busy(void)
{
unsigned char b=0;
RS=0;RW=1;E=0;
IO=255;
E=1;
if(BF){b=1;}
return(b);
}
/*****初始化LCD****/
void inital(void)
{
IO=1; /*1:(0000 0001)清屏,光標回位*/
RS=0;RW=0;E=0;
while(busy()){;}
IO=56; /*2:(0011 1000)8位總線,2行顯示,5*7點陣*/
RS=0;RW=0;E=0;
while(busy()){;}
IO=15; /*3:(0000 1111)整體顯示開,顯示光標,光標閃爍開*/
RS=0;RW=0;E=0;
while(busy()){;}
IO=6; /*4:(0000 0110)光標右移*/
RS=0;RW=0;E=0;
}
|