Question
Interfacing STM32L476 with HD44780 LCD Display Driver
Posted on March 09, 2016 at 16:37
To generate code (initialization and so on) I used the STM32CubeMX.
LCD Initialization function is written by me (based on what's here: http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html)
I would be very grateful if somebody could help me.
Best regards,
TSM
#hd44780 #stm32l4 #hal #lcd-display
Hello,
Recently I got the STM32L476 Nucleo-64 board. Now I am trying to interface it with LCD display.
To generate code (initialization and so on) I used the STM32CubeMX.
LCD Initialization function is written by me (based on what's here: http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html)
#define Bit_SET GPIO_PIN_SET
#define Bit_RESET GPIO_PIN_RESET
void LCD_WriteNibble(unsigned char nibbleToWrite)
{
int delayCnt;
HAL_GPIO_WritePin(LCD_Ctrl_Port, LCD_EN_Pin, Bit_RESET);
for(delayCnt=0; delayCnt<5000; delayCnt++);
HAL_GPIO_WritePin(LCD_Data_Port, LCD_D4_Pin, (nibbleToWrite & (unsigned char)0x01));
HAL_GPIO_WritePin(LCD_Data_Port, LCD_D5_Pin, (nibbleToWrite & (unsigned char)0x02));
HAL_GPIO_WritePin(LCD_Data_Port, LCD_D6_Pin, (nibbleToWrite & (unsigned char)0x04));
HAL_GPIO_WritePin(LCD_Data_Port, LCD_D7_Pin, (nibbleToWrite & (unsigned char)0x08));
HAL_GPIO_WritePin(LCD_Ctrl_Port, LCD_EN_Pin, Bit_SET);
for(delayCnt=0; delayCnt<5000; delayCnt++);
HAL_GPIO_WritePin(LCD_Ctrl_Port, LCD_EN_Pin, Bit_RESET);
}
void LCD_Init2()
{
int i=0, delayCnt=0;
for (delayCnt=0;delayCnt<1000000;delayCnt++);
GPIO_ResetBits(GPIOA, LCD_RS_Pin | LCD_EN_Pin | LCD_RW_Pin);
for(i = 0; i < 3; i++) {
LCD_WriteNibble(0x03);
for(delayCnt = 0; delayCnt < 1000000; delayCnt++);
}
LCD_WriteNibble(0x02);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x02);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x02);
LCD_WriteNibble(0x08);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x00);
LCD_WriteNibble(0x08);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x00);
LCD_WriteNibble(0x01);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x00);
LCD_WriteNibble(0x06);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
LCD_WriteNibble(0x00);
LCD_WriteNibble(0x0C);
for(delayCnt = 0; delayCnt < 600000; delayCnt++);
}
Unfortunately, it isn't working and I can't figure out why. There is still a bunch of rectangles in upper row:
I would be very grateful if somebody could help me.
Best regards,
TSM
#hd44780 #stm32l4 #hal #lcd-display