2023-02-23 01:17 AM
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?
2023-02-23 02:07 AM
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).
2023-02-23 07:14 AM
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?
2023-02-25 12:44 AM
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.