STM8L-Discovery and LCD 2x16 display with KS0066U controller.

Today I'm showing how to interact with one of the most popular displays which is 16 characters x 2 lines LCD. The part which I have is display from Windcom Tech WC1602A-STBLWNC06. It has KS0066U or S6A0069 controllers inside( documentation isn't clear about this topic) which are similar with old good Hitachi HD44780 controllers. In order to interact with my display I'm going to use evaluation kit from ST Microelectronics which is called STM8L-Discovery. The evaluation kit is really cheap and worth to buy it, as far as I know you can purchase it for about 10$. On board of STM8L-Discovery we have STM8L152C6 microcontroller which is very good alternative for old AVR family from Atmel. With our micro we got 32KB of Flash memory 2KB of RAM and 1KB of EEPROM and a lot of peripherals. Nevertheless, STM8 family isn't very popular among amateur electronics, that's why it's time to change it. After you already bought your discovery kit it's time to think about compiler. Here you have two ways, you can go with SDCC a open source compiler which is completely free of charge. Or the seconds way is to order some evaluation version of compiler from Cosmic Software ,they are giving a one year license with code size limitation to 32KB. I chose the second way because as gcc guy I was intrigued how proprietary compiler looks like. After getting compiler I've started to tamper a little bit with it. Running blinking diode was of course first task, then I jumped to connection of my display:

 

schematic1Pic.1 Schematic presents connection of LCD 2x16

 

Schematic is done with Eagle with help of display symbol from Adafruit library. What is important on the above schematic is that VDD and anode of backlight diode is connected to the +5V supply voltage. You can easily find this voltage on STM8L-Discovery kit. Second important thing is that V0 pin on the display which supports contrast setting is connected to the ground, this is how I'm achieving full setting of the contrast. Display will be controlled in 4-bit mode, that's why only data lines DB4-DB7 are wired. Please remember that you should never ever connect rest of data bus lines DB0-DB3 to the ground, it can just fry your display. The reason for that is that most of those displays starts in 8-bit mode and it might happen that DB0-DB3 will be set to push-pull GPIO before proper initialization of display to 4-bit mode will be performed. It will then cause shortcut to the ground and as I said before it'll fry your display. Data and control bus lines are connected directly to the pin headers of STM8L-Discovery. Both buses are working with display logic despite of voltage high state is up to +3.3V.  Proper connection of display manifest with displaying squares like on picture below:

 

squaresPic.2 Squares are visible with proper connection

 

What we need to do right now is writing some piece of code for initialization and some functions for sending text to the display. Library code can be found on my github account under the link:

Display driver

Driver is part of bigger project which will be presented in future posts, however you can easily take it separately and fit it into your project. On the picture below connected STM8L-Discovery and WC1602A-STBLWNC06 display with "Hello world!!!" text on it.

 

connectionPic.2 "Hello world" on the display

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.