我在做1602显示的时候发现:
定位在某一个位置上显示字符,但是在第一行第一个字符会循环显示屏上所有的字符.
初始化程序如下:
void lcd_init(void)
{
LCD_DATA=0;
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
read_busy();
LCD_DATA=0x38;
lcd_enable();
read_busy();
LCD_DATA=0x08;
lcd_enable();
read_busy();
LCD_DATA=0x01;
lcd_enable();
read_busy();
LCD_DATA=0x06;
lcd_enable();
read_busy();
LCD_DATA=0x0e;
lcd_enable();
}
不知道有没有人遇到过同样的情况呢,不知道你们是如何解决的呢.
问个1602的显示问题(C语言)
全部回复(4)
正序查看
倒序查看
现在还没有回复呢,说说你的想法
#include
#define uchar unsigned char
#define LCD_DATA P2
sbit LCD_RS=P0^5;
sbit LCD_RW=P0^6;
sbit LCD_EN=P0^7;
void delays(uchar a)
{
uchar j;
while(--a!=0)
{
for(j=0;j<125;j++);
}
}
void read_busy(void)
{
LCD_DATA=0xff;
LCD_RS=0;
LCD_RW=1;
LCD_EN=0;
delays(1);
LCD_EN=1;
while(LCD_DATA&0x80);
}
void lcd_enable(void)
{
LCD_RS=0;
LCD_RW=0;
LCD_EN=0;
delays(1);
LCD_EN=1;
}
void lcd_init(void)
{
LCD_DATA=0;
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
read_busy();
LCD_DATA=0x38;
lcd_enable();
read_busy();
LCD_DATA=0x08;
lcd_enable();
read_busy();
LCD_DATA=0x01;
lcd_enable();
read_busy();
LCD_DATA=0x06;
lcd_enable();
read_busy();
LCD_DATA=0x0f;
lcd_enable();
}
void dis_one_char(uchar y,uchar x,uchar char_data)
{
y&=0x01;
x&=0x0f;
if(y)
{
x|=0x40;
}
x|=0x80;
LCD_DATA=x;
lcd_enable();
read_busy();
LCD_DATA=char_data;
LCD_RS=1;
LCD_RW=0;
LCD_EN=0;
delays(1);
LCD_EN=1;
}
void main(void)
{
uchar i;
for(i=0;i<125;i++)
{
delays(5);
}
lcd_init();
delays(5);
while(1)
{
dis_one_char(0,3,'A');
dis_one_char(1,5,'B');
dis_one_char(0,8,'C');
dis_one_char(1,12,'D');
// while(1);
}
}
#define uchar unsigned char
#define LCD_DATA P2
sbit LCD_RS=P0^5;
sbit LCD_RW=P0^6;
sbit LCD_EN=P0^7;
void delays(uchar a)
{
uchar j;
while(--a!=0)
{
for(j=0;j<125;j++);
}
}
void read_busy(void)
{
LCD_DATA=0xff;
LCD_RS=0;
LCD_RW=1;
LCD_EN=0;
delays(1);
LCD_EN=1;
while(LCD_DATA&0x80);
}
void lcd_enable(void)
{
LCD_RS=0;
LCD_RW=0;
LCD_EN=0;
delays(1);
LCD_EN=1;
}
void lcd_init(void)
{
LCD_DATA=0;
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
LCD_DATA=0x38;
delays(5);
read_busy();
LCD_DATA=0x38;
lcd_enable();
read_busy();
LCD_DATA=0x08;
lcd_enable();
read_busy();
LCD_DATA=0x01;
lcd_enable();
read_busy();
LCD_DATA=0x06;
lcd_enable();
read_busy();
LCD_DATA=0x0f;
lcd_enable();
}
void dis_one_char(uchar y,uchar x,uchar char_data)
{
y&=0x01;
x&=0x0f;
if(y)
{
x|=0x40;
}
x|=0x80;
LCD_DATA=x;
lcd_enable();
read_busy();
LCD_DATA=char_data;
LCD_RS=1;
LCD_RW=0;
LCD_EN=0;
delays(1);
LCD_EN=1;
}
void main(void)
{
uchar i;
for(i=0;i<125;i++)
{
delays(5);
}
lcd_init();
delays(5);
while(1)
{
dis_one_char(0,3,'A');
dis_one_char(1,5,'B');
dis_one_char(0,8,'C');
dis_one_char(1,12,'D');
// while(1);
}
}
0
回复
提示