I am working with a Winstar Display LCD ( WH2004A-YYK-CP ) and STM32 processor and codes are written in C. I need to run it with 4-bit mode. I run it and wrote what I wanted.

As you know, 4-bit mode send 8-bit data as 2 times 4bit. The problem is, when I reset between 2 nibbles, it prints strange characters, and no matter how much I reset it, it is not working properly. The only solution I came up is resetting it several times.

To figure out what is going on, I added 2 second delay between 2 nibbles (4-bit each), and print a long sentence. therefore whenever I reset it, processor waiting to send second nibble.

I am resetting it, it prints something strange, after second reset it prints nothing, and after third one it prints again correctly. and 4th reset it again prints something strange, 5th one prints nothing and 6th one again prints correctly ... and goes on like this. Therefore I am now sure that problem is these divided bytes.

Similar code works perfectly fine with 8bit mode.

What I am asking is here: How can I be sure that "when I reset STM32 processor, LCD is not waiting second nibble of some data whose first nibble is sent in the previous session." by using C codes?

UPDATE:

I also send my code here: http://pastebin.com/kHQQEqjx

LCD commands are also here: http://imgur.com/mfDlj

有帮助吗?

解决方案

Here is the flowchart that details all the steps required to initialize that LCD controller in 4 bit mode.

enter image description here

其他提示

Normally, there would be a way of resetting the LCD device, which you would do as part of the startup for the processor.

That way, a reset of the processor would also put the LCD in a known state.

You need to get a hold of the data sheet (or other programming spec) and see how it's meant to be done. There's almost certainly a way to get the LCD back to a known initial state.

Otherwise, you may need to tie the reset switch to both the processor and the LCD controller.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top