Home > other >  Stm32 drive LCD1602 problem
Stm32 drive LCD1602 problem

Time:12-03

I use stm32f103zet6 board drive a LCD1602 LCD, let it in the first row shows abcdefghijklmnop,
Wiring is PB0 ~ 2 RS, RW, EN, PA0 ~ 7 D0 ~ D7
But the display is shown below the

Then I will be disconnected again reset the MCU LCD, again found to function after connected to the power of the LCD display, the following figure

But if keep off the LCD power supply will microcontroller reset display is still wrong, please, feel free to grant instruction!!!!!!

Below is a code, key. There is a delay function h

# include "stm32f10x. H"
H # include "is the key."

# define Set_RS GPIO_SetBits (GPIOB, GPIO_Pin_0)
# define Set_RW GPIO_SetBits (GPIOB, GPIO_Pin_1)
# define Set_EN GPIO_SetBits (GPIOB, GPIO_Pin_2)

# define CLR_RS GPIO_ResetBits (GPIOB, GPIO_Pin_0)
# define CLR_RW GPIO_ResetBits (GPIOB, GPIO_Pin_1)
# define CLR_EN GPIO_ResetBits (GPIOB, GPIO_Pin_2)

GPIO_InitTypeDef GPIO_InitStructure;

Unsigned char table []="abcdefghijklmnop";

Void Send_Com (unsigned char Send_Com)
{

CLR_RS;
GPIO_Write (GPIOA, under-16 Send_Com);
Delay_ms (5);
Set_EN;
Delay_ms (5);
CLR_EN;
}

Void Send_Dat (unsigned char Send_Dat)
{

Set_RS;
GPIO_Write (GPIOA, Send_Dat);
Delay_ms (5);
Set_EN;
Delay_ms (5);
CLR_EN;
}
Void init ()
{
CLR_EN;
X38 Send_Com (0);
X0c Send_Com (0);
Send_Com x06 (0);
Send_Com (0 x01);

}
Void GPIO_Configuration (void)
{
GPIO_InitStructure. GPIO_Pin=GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStructure. GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure. GPIO_Mode=GPIO_Mode_Out_PP;
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE);
GPIO_Init (GPIOB, & amp; GPIO_InitStructure);
GPIO_InitStructure. 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_InitStructure. GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure. GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_Init (GPIOA, & amp; GPIO_InitStructure);



}




Int main (void)
{

Unsigned char num.

GPIO_Configuration ();

init();

Send_Com (0 x80);

For (num=0; Num<=15; Num++)
{
Send_Dat (table (num));
Delay_ms (1);
}
While (1);

}

CodePudding user response:

A very common problem is the MCU reset speed over 1602, 1602 abnormal.
STM32 after start-up delay in operating 1602 look at in a minute

CodePudding user response:

reference 1st floor wangfan027 response:
is a very common problem MCU reset speed over 1602, 1602 abnormal.
STM32 delay for a while in the operation of 1602 since the start to see

I before the main function of 1602 initialization time delay for a long time, still can appear the same problem

CodePudding user response:

Senfd_Com and set the time delay in the Send_Dat bigger!!!! Nine times out of ten are this problem , LCD1602 itself is slow response are you busy this program without reading action will pay attention to every write a time delay should be longer too fast!

CodePudding user response:

Will the JTAG inside disabled, because your board MCU processing speed and the speed of LCD, led to read data is flawed, specific operation as follows
RCC_APB2PeriphClockCmd (RCC_APB2Periph_AFIO, ENABLE);
GPIO_PinRemapConfig (GPIO_Remap_SWJ_JTAGDisable, ENABLE);//banned the JTAG function

CodePudding user response:

Hello this is driven directly to 1062? You

CodePudding user response:

Initialize the event is not enough, more than 1602 initialization need dozens of ms, increase before use to have enough wait for events

CodePudding user response:

LCD1602 belongs to slow devices, signal need to give enough time delay between

  • Related