LCD DISPLAY


Description

An LCD display is used as the output portion of the user interface. The display used is 128x128 pixels and is configured to use 6x8 characters. This gives 16 lines of 21 characters. It uses a Toshiba T6963C controller chip which supports both text and graphics. However, only text is used in the project.

Circuit

The LCD subcircuit is just a bunch of wires. PortA is connected to the data pads of the LCD module. PortC is used as a control port. Pin 6 is ~WR, pin 5 ~RD, pin 4 ~CE, pin3 C/~D, and pin 2 ~Reset. Pins 7, 1, and 0 are not used. The LED backlight that is built into the display is also not used.

Additionally the LCD requires around -18V for contrast biasing. This Vee is provided by an external lab power supply.

Driver

-> The document "Using the T6963 based graphic display" was very useful in developing this driver. See the links page.<-

The LCD driver is based on the 2 functions WriteDataToLCD() and WriteCommandToLCD(). However, before either data or commands can be sent to the LCD the AVR needs to see if the LCD is busy. This is done by making PortA an input and setting the control lines to read the status byte (~WR = 1, ~RD = 0, ~CE = 0, C/~D = 1, ~Reset = 1). After waiting a few cycles to make sure the data is stable the status byte is read from the PINA register and PortA is switched back to an output. If STA0 and STA1 (bits 0 and 1 of the status byte) are 1 then the LCD is ready for commands or data to be sent.

WriteDataToLCD() first checks the LCD status as described. Then it puts the data on PortA and sets the control lines to write data (~WR = 0, ~RD = 1, ~CE = 0, C/~D = 0, ~Reset = 1). WriteCommandToLCD() does the same except commands are put onto PortA and the control lines are set to write a command (~WR = 0, ~RD = 1, ~CE = 0, C/~D = 1, ~Reset = 1). These two functions are then used to control the LCD. Usually one or two bytes of data must be sent followed by a command.

Before it can be used the LCD must be initialized. The T6963C can support both text and graphics, but only text is used. Therefore we set the text home address to address 0 and the graphics address high enough so that it will not overlap. Similarly the user defined CG RAM area is set to a high enough address because it is not used either.

The area must also be set for text and graphics. This is basically how many columns there are. The font used is 6 pixels wide and the screen is 128 pixels wide. Thus there are 21.333 columns, which is rounded up to 22. Rounding up means the software must be able to print a space every 21 characters so that the 22nd column remains blank. However, if it was rounded down to 21 then some characters would partially appear on one line and partially on the next if they happened to be at the end of a line.

Additional commands to set the mode (internal CG ROM and OR mode are specified), set the cursor size (8 pixels high), set the cursor type (blinking), and turn the screen on are also sent to complete initialization.

Now the LCD is ready for use. Two functions are provided for displaying characters on the screen. WriteCharToLCD() commands the LCD to display a single character and the current address and increment the address for the next command. WriteBufferToLCD() is similar except that it will send commands for each character in a buffer, displaying up to a whole screen at once. This is useful when a page is loaded from memory and needs to be shown on screen. WriteBufferToLCD() adds the additional spaces for the 22nd column, but WriteCharToLCD() does not.

Other functions provided by the LCD driver set the address and cursor positions. Setting the address allows the positioning of text anywhere on the screen. ClearLCDScreen() writes the space character to every position visible on the screen.





Written by Mike Lombardo. 12/12/01