cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing STM32L476 with HD44780 LCD Display Driver

tsmolarek
Associate
Posted on March 09, 2016 at 16:37

Hello,

Recently I got the STM32L476 Nucleo-64 board. Now I am trying to interface it with LCD display. 0690X00000605acQAA.png 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: 0690X00000603MYQAY.jpg I would be very grateful if somebody could help me. Best regards, TSM #hd44780 #stm32l4 #hal #lcd-display
2 REPLIES 2

Dear Sir

On the old community site, I had produced a set of tutorials that disappeared during the migration.

I'll try to attach my library sources to this email. I hope it will help you.

JC

Yes, the larger posts seem to have an issue, you'll need to talk to @brk​ about transition efforts/schedules.

Here the Format Code Block data is damaged too.

I would however generally advise against posting answers to threads which are several years old, the OP is unlikely to find the answer or be alerted.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..