Introduction

The 128×64 GLCD can be used to display text, logos, graphs, shapes and other useful bit images. To interface the GLCD with the LPC1768, we need 8 data pins and 6 control pins. In this tutorial, we will be using the KS0108 GLCD library from http://en.radzio.dxp.pl/ks0108/.
We will be discussing how to develop a program to run this library.

Basic Configuration

  • The 128×64 GLCD contains 8 data pins.
  • There are 6 control pins of which 3 are similar to the ones used for the 16×2 character LCD; En-Enable, R/W-Read/Write Bit and the RS-Register Select bit.
  • A fourth pin is the RST or the reset pin used for resetting the module. (This is commonly known as CS3 or chip select 3)
  • Finally, we have the chip select pins of the internal controller CS1 and CS2.

128x64 GLCD display pins

Programming

  • DEFINITIONS: We will be using the KS0108-LPC.c file that is used for the low-level driver for NXP LPC2000 ARM-core MCU.
    Since we are using a different controller, a few modifications have been made in the definition of this file alone in order for it to be compatible while using the LPC1768 MCU and our OpenLab platform.
    The definitions have been modified in such a way that we will be using pins from 16 to 23 of PORT0 as data pins and pins 16 to 21 of PORT1 as control pins. The modified definitions have been given below.

     
  • INITIALIZATION: Include all the necessary header files and then start by initializing the GLCD using the function GLCD_Initalize().
  • DISPLAYING SHAPES: First, we will be displaying a few shapes and for that, we will be using the graphics.c library file from the same link given above. Using the GLCD_Rectangle() and GLCD_Circle(), we will be drawing a two-dimensional rectangle and circle on the screen.
    The GLCD_Rectangle() takes four function parameters. The first two parameters indicate the starting position from where the rectangle must be drawn (Top left corner of the rectangle). The next two parameters define the length and breadth of the rectangle.
    The GLCD_Circle() takes three function parameters. The first two parameters indicate the position of the circle and the third parameter defines the radius of the circle.
  • The ClearScreen and GoTo functions are utility functions. ClearScreen helps in clearing all the data that is displayed on the GLCD screen and the GoTo function helps to get to a particular location of the screen.
  • DISPLAYING TEXT: The text is displayed using the GLCD_WriteString function. For each character in a text, the 5×8 matrix two-dimensional data is stored in a one-dimensional array in the font5x8.h header file. This memory is accessed every time we try to write a text or a character.
  • DISPLAYING LOGO: Next we display a logo. It takes 5 function parameters. The first parameter is the logo data stored in the form of a one-dimensional array. The next two parameters determine the position of the logo and the final two parameters define the length and breadth of the logo. Any type of logo can be converted to its bitmap using the application in this link http://en.radzio.dxp.pl/bitmap_converter/

Summary

We have learned to use the KS0108 driver library from radzio.dxp and created a program to run the library using LPC1768 MCU. The code based on this tutorial is available in the Code Library

Liked this article! You'll love our video courses.
Checkout our comprehensive pre-recorded Video Courses for ARM Cortex Microcontrollers
More details
Free Embedded C course with this course for a short period of time
Spread the love, share this