cancel
Showing results for 
Search instead for 
Did you mean: 

16x2 character lcd driver

pranamesh
Associate II
Posted on September 26, 2008 at 13:32

16x2 character lcd driver

5 REPLIES 5
pranamesh
Associate II
Posted on May 17, 2011 at 12:45

hello!

does any one got sample code for running the 16x2 and 20x4 character lcd for STM32

thanks in advance

jj
Associate II
Posted on May 17, 2011 at 12:45

If you need guidance quickly I present this:

Character modules can operate with just 6 outputs - 4 data, an RS and E strobe. RS=H is data, RS=L is command. We do not recommend this - you will condemn yourself to ''text-only'' modules by electing 4 bit only data. By using 8 bit data and 4 control lines you can extend all the way up to QVGA (320x240) Graphic Lcds.

Major areas requiring attention:

a) Contrast pin (usually pin 3) will normally be adjusted ''near'' 0V (gnd). You should just be able to see the dot field when the display has been cleared. If the voltage is too positive the display will be unviewable.

b) Allow for the set-up time between RS and E. This means that data and RS can be loaded in 1 instruction but E must wait for a 2nd instruction (to set) and a 3rd (to clear). If you employ an 8 bit bus this will extend to 4 instructions: data, RS, E-Hi, E-Lo. *** Should you be using a new FSMC part you can tie to FSMC bus and achieve a display transaction in a ''single'' instruction.

c) When you clear the Lcd (RS=L, data=0x01) the Lcd will ''go busy'' for almost 2mS. You must insert delays or ''read the Lcd's busy flag'' to prevent loss of subsequent data.

d) Basic character writes require ~40uS for the Lcd to execute. Again you need delays/busy read to prevent over-writes.

e) These displays do not nicely shift from line 1 to 2, and from line 2 to 3 or 3 to 4. You have to track the cursor - and implement this cursor write in your software.

f) Remember to initialize the Lcd - vitally important should you elect 4 bit mode. Add extra length delays during this initialization process.

It is often desirable to read stored messages from an 8 pin eeprom and to read ''live'' data coming from a serial port. The Lcd contains 80 bytes of ram (even a 2x16) and you should use this where/when possible. Should more data be arriving you need to dedicate a buffer w/in STM32.

This should get you going - by the way - in ''most'' cases a 5V Lcd will accept the STM32's 3V3 data & control levels - when the Lcd is powered with 5V. Should you power the Lcd with 3V3 it is likely that you will have to adjust the pin 3 ''contrast'' pin below ground. (2-3V negative should do - but this is maker/module dependent)

[ This message was edited by: jj.sprague on 23-09-2008 06:12 ]

jj
Associate II
Posted on May 17, 2011 at 12:45

My firm will be linking/posting such code in the near future. In addition - our Character & Graphic Modules include SPI, I2C and Uart I/O - making them the most flexible. Each I/O supports a keypad and NAV Switch too (2-way) easing/reducing the signal demands upon the STM32.

One of our newest devices provides Character Module compatibility - yet provides full graphic capability too - and bright Led backlights in a variety of colors. (blue, green, yellow, red, white) This new Lcd enables 4 rows of 24 characters - or 2 rows of 16 or 1 row of 9 - in addition to full-pixel graphics - all in the size/cost of a standard 2x16 Lcd!

pranamesh
Associate II
Posted on May 17, 2011 at 12:45

thanks every one for your comments and inputs!, let me get this myself for now. I am using the free OpenOCD eclipse based GNU toolchain for my dev. I will post my code for any one else's use.

jaroslaw2
Associate II
Posted on May 17, 2011 at 12:45

Hi,

I took LCD drivers from example programs for Keil MCBSTM32 evaluation board. What I can advise you is to install free version of Keil software and check the folder with example programs.

Remember to not use optimization in compiler options.

Sorry, but I can not post this code hire.

good luck,

J.O.

[ This message was edited by: jaroslaw.oska on 23-09-2008 21:56 ]