cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing LCD1602A with STM32F411RE

akoluacik
Senior

Hey,

I wanna interface LCD1602A with my MPU, STM32F411RE. I looked at the document of LCD but there are lots of it from different manufacturers. There isn't any sign on my LCD about its manufacturer. Though, anyway, I wanna implement its driver code using HAL Library. However, I cannot understand how to do it, because one of the document described the initialization process while others didn't.

Is there anyone who explain me how to do that? Or a good source for this?

3 REPLIES 3
gbm
Lead III

Using HAL is an overkill.

Use 4-bit interface with R/-W line permanently connected to 0 (don't use busy flag as it's useless). Since any STM32 is much faster than LCD interface, I usually control the character LCD in a timer interrupt routine invoked with 2..10 kHz frequency, using a two-level state machine implemented in software. You can do it also in a classic way but then you must insert 500 ns delays between E signal changes (= almost 50 NOPs on F411).

Thx for your answer.

I am trying to implement a driver to learn. HAL may be overkill but it does not matter for me right now.

Why do I need to connect RW to 0? And you mean I connect R/W, for instance, to PA0 pin and it always RESET?

And how do you know 500ns delay is required?

gbm
Lead III

Your display, like 99% of LCD character displays, uses HD44780-compatible controller. Just read the HD44780 datasheet. 44780 is designed for up to 2 MHz E signal operation - hence the 250 ns minimum E toggle period. Maximum timeouts are specified for each command - these may be easily implemented with software timer using hw timer interrupt. HD44780 BUSY flag goes inactive while the command is still in progress, so it doesn't have too much use with fast microcontrollers. R/-W pin may be simply connected to GND. 4-bit interface requires only 6 MCU pins.