单片机lcd屏幕的问题 为甚么整个屏幕一直在闪动
#include<reg52.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbi...
#include <reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit RS=P2^4;
sbit RW=P2^5;
sbit EN=P2^6;
sbit lcden=P2^6;
void Write_Com(unsigned char com) ;
#define RS_CLR RS=0
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define DataPort P0
void delay(uchar t);
void LCD_Init(void)
{
Write_Com(0x38); /*显示模式设置*/
delay(5);
Write_Com(0x38);
delay(5);
Write_Com(0x38);
delay(5);
Write_Com(0x38);
Write_Com(0x08); /*显示关闭*/
Write_Com(0x01); /*显示清屏*/
Write_Com(0x06); /*显示光标移动设置*/
delay(5);
Write_Com(0x0F); /*显示开及光标设置*/
}
void Write_Com(unsigned char com)
{
// while(LCD_Check_Busy()); //忙则等待
delay(5);
RS_CLR;
RW_CLR;
DataPort=com;
EN_SET;
_nop_();
EN_CLR;
}
void Write_Dat(unsigned char com)
{
// while(LCD_Check_Busy()); //忙则等待
delay(5);
RS_SET;
RW_CLR;
EN_SET;
DataPort=com;
_nop_();
EN_CLR;
}
void delay2ms(uchar t)
{
while(--t);
}
void delay(uchar t)
{
while(t--)
delay2ms(245);
delay2ms(245);
}
void LCD_Clear(void)
{
Write_Com(0x01);
delay2ms(5);
}
void main()
{
LCD_Init();
LCD_Clear();
Write_Dat('c');
Write_Dat('h');
Write_Dat('e');
Write_Dat('n');
Write_Dat('w');
Write_Dat('e');
Write_Dat('i');
Write_Dat('t');
Write_Dat('i');
Write_Dat('a');
Write_Dat('n');
} 展开
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit RS=P2^4;
sbit RW=P2^5;
sbit EN=P2^6;
sbit lcden=P2^6;
void Write_Com(unsigned char com) ;
#define RS_CLR RS=0
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define DataPort P0
void delay(uchar t);
void LCD_Init(void)
{
Write_Com(0x38); /*显示模式设置*/
delay(5);
Write_Com(0x38);
delay(5);
Write_Com(0x38);
delay(5);
Write_Com(0x38);
Write_Com(0x08); /*显示关闭*/
Write_Com(0x01); /*显示清屏*/
Write_Com(0x06); /*显示光标移动设置*/
delay(5);
Write_Com(0x0F); /*显示开及光标设置*/
}
void Write_Com(unsigned char com)
{
// while(LCD_Check_Busy()); //忙则等待
delay(5);
RS_CLR;
RW_CLR;
DataPort=com;
EN_SET;
_nop_();
EN_CLR;
}
void Write_Dat(unsigned char com)
{
// while(LCD_Check_Busy()); //忙则等待
delay(5);
RS_SET;
RW_CLR;
EN_SET;
DataPort=com;
_nop_();
EN_CLR;
}
void delay2ms(uchar t)
{
while(--t);
}
void delay(uchar t)
{
while(t--)
delay2ms(245);
delay2ms(245);
}
void LCD_Clear(void)
{
Write_Com(0x01);
delay2ms(5);
}
void main()
{
LCD_Init();
LCD_Clear();
Write_Dat('c');
Write_Dat('h');
Write_Dat('e');
Write_Dat('n');
Write_Dat('w');
Write_Dat('e');
Write_Dat('i');
Write_Dat('t');
Write_Dat('i');
Write_Dat('a');
Write_Dat('n');
} 展开
3个回答
展开全部
缺少循环,程序,跑飞了。
……
void main()
{
LCD_Init();
LCD_Clear();
Write_Dat('c');
……
Write_Dat('n');
while(1); //--加上这句,即可不闪。
}
……
void main()
{
LCD_Init();
LCD_Clear();
Write_Dat('c');
……
Write_Dat('n');
while(1); //--加上这句,即可不闪。
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在主函数结尾加个“while(1);”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询