求指教。.
时间:10-02
整理:3721RD
点击:
测试程序在protues里可以显示字母,在实际lcd中却只显示一整行的光亮,这是硬件问题还是程序问题?
#include <STC12C5A60S2.h>
#include <intrins.h>
sbit LCDEN=P3^5;
sbit RS=P3^4;
#define uint unsigned int
#define uchar unsigned char
void LCDcom(uint com);
void Delay(uint n);
void LCDinit() //1602初始化
{
LCDEN=0;
LCDcom(0x38);
Delay(5);
LCDcom(0x38);
Delay(5);
LCDcom(0x38);
Delay(5);
LCDcom(0x08);
Delay(5);
LCDcom(0x0c); //开显示,不显示光标
Delay(5);
LCDcom(0x01); //清屏
Delay(5);
}
void LCDcom(uint com) //1602写命令
{
RS=0;
P2=com;
Delay(5);
LCDEN=1;
Delay(5);
LCDEN=0;
}
void LCDdata(uchar date) //1602写数据
{
RS=1;
P2=date;
Delay(5);
LCDEN=1;
Delay(5);
LCDEN=0;
}
main()
{ LCDinit();
while(1)
{
LCDcom(0x80);
LCDdata('A');
}
}
void Delay(uint n)
{
double x;
while(n--)
{
x=1000;
while(x--);
}
}
#include <STC12C5A60S2.h>
#include <intrins.h>
sbit LCDEN=P3^5;
sbit RS=P3^4;
#define uint unsigned int
#define uchar unsigned char
void LCDcom(uint com);
void Delay(uint n);
void LCDinit() //1602初始化
{
LCDEN=0;
LCDcom(0x38);
Delay(5);
LCDcom(0x38);
Delay(5);
LCDcom(0x38);
Delay(5);
LCDcom(0x08);
Delay(5);
LCDcom(0x0c); //开显示,不显示光标
Delay(5);
LCDcom(0x01); //清屏
Delay(5);
}
void LCDcom(uint com) //1602写命令
{
RS=0;
P2=com;
Delay(5);
LCDEN=1;
Delay(5);
LCDEN=0;
}
void LCDdata(uchar date) //1602写数据
{
RS=1;
P2=date;
Delay(5);
LCDEN=1;
Delay(5);
LCDEN=0;
}
main()
{ LCDinit();
while(1)
{
LCDcom(0x80);
LCDdata('A');
}
}
void Delay(uint n)
{
double x;
while(n--)
{
x=1000;
while(x--);
}
}
请问,你的lcd1602的RW引脚硬件是怎么联的?rw引脚电平不定可能造成显示不出字符,希望对你有帮助
1602