中级会员
 
- 积分
- 323
- 金钱
- 323
- 注册时间
- 2018-1-23
- 在线时间
- 40 小时
|
LCD1602A 反复调试无法显示 求助大神
硬件的接先仔细核对过很多遍,没有问题,现在就是连黑格子都不显示
void LCD1602A_CONFUG()
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOD,ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_1|GPIO_Pin_0;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE,&GPIO_InitStruct);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD,&GPIO_InitStruct);
}
void LCD1602_Wait_Ready()
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD ,&GPIO_InitStructure);
RS = 0;
delay_us(50);
RW = 1;
do
{
EN = 1;
GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7);
delay_us(200);
EN = 0;
}while(GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7));
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD ,&GPIO_InitStructure);
}
void LCD1602_Write_Cmd(uchar cmd)
{
unsigned int data;
LCD1602_Wait_Ready();
RS = 0;
delay_us(50);
RW = 0;
data=cmd<<8;
GPIO_Write(GPIOD, data);
EN = 1;
delay_us(200);
EN = 0;
delay_us(50);
}
void LCD1602_Write_Dat(uchar dat)
{
unsigned int data;
LCD1602_Wait_Ready();
RS = 1;
delay_us(50);
RW = 0;
data=dat<<8;
GPIO_Write(GPIOD,data);
EN = 1;
delay_us(200);
EN = 0;
delay_us(50);
}
void LCD1602_Dis_OneChar(u8 x, u8 y,u8 dat)
{
if(y) x |= 0x40;
x |= 0x80;
LCD1602_Write_Cmd(x);
delay_us(50);
LCD1602_Write_Dat(dat);
}
void LCD1602_Show_Str(u8 x, u8 y, uchar *str)
{
if(y) x |= 0x40;
x |= 0x80;
LCD1602_Write_Cmd(x);
while(*str != '\0')
{
LCD1602_Write_Dat(*str);
str++;
}
}
void LCD1602_Init(void)
{
delay_ms(10);
LCD1602_Write_Cmd(0x38); //ÏÔê¾Ä£ê½éèÖÃ
LCD1602_Write_Cmd(0x08);
LCD1602_Write_Cmd(0x06);
LCD1602_Write_Cmd(0x0c);
LCD1602_Write_Cmd(0x01);
}
|
|