Graphics LCD Interfacing With Armv7 LPC 2148: Embedded System Design Mini Project

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 17

EMBEDDED SYSTEM DESIGN

Mini Project

GRAPHICS LCD INTERFACING WITH ARMV7


LPC 2148
Under the guidance of

Mr. Mohd Ziauddin Jahangir

Asst.professor,cbit

BATCH MEMBERS:

Kiran Kumar:- 1601-16-735-331

Vedavyas :- 1601-16-735-178

Navya :- 1601-16-735-334

Lecturer sign:-__________________
ABSTRCT
The real world devices such as Liquid crystal displays (LCDs), Stepper motor,
Analog to Digital converter and Digital to Analog converter and sensors can be
interfaced with the ARM processor. LCDs are extensively used in today’s world to
display numbers, characters as well as graphics. Whenever the user wants to get
the directions or data values the microprocessors and microcontrollers play a vital
role in displaying the letters of the alphabet and numbers. Whenever there is a
need for large amount of data to be displayed Cathode ray tube (CRT) is a good
option to display the data. On the other hand when a small amount of data is to
be displayed, simple digit type graphical displays are generally used. The graphical
displays use various technologies.Higher performance microcontrollers is the need
of the hour and has a significant impact on the industry’s changing needs, such as
the case where microcontrollers are needed to handle bulk of the work without
increasing a product’s frequency or power. Now a days ARM controllers are
drawing attention owing to its numerous advantages.

The state of the art presented in this paper is the interfacing of GRAPHICAL
LCD with ARM controller LPC2148 to display a suitable images and text on it. Here
we used a 128*64 GLCD to interface. We can display any image on glcd in black
and white colour. The GLCD is controlled by ks0108 driver controller which is
drives the GLCD to display the given binary data as image.
INTRODUCTION
Description of GLCD:
The GLCD is divided into two parts which are controlled by two different
controllers. Each of these parts is divided into rows and columns.To interface this
GLCD with microcontroller, two registers (Input and Output register) are provided
in the LCD. These registers are selected by the combination of RS and RW signals.
These combinations are given in the following Table1.

Input Register:

Input Register is used while giving instructions and writing data to LCD. It holds
the data/instruction temporarily before writing to DDRAM (Data Display
RAM).When the LCD is in active mode (CS1 and CS2 high), the Input register can
be selected by sending bits on RS and RW pins as shown in the following table.
The data of input register is latched in at the falling edge (from high to low) of EN
(Enable) signal and written into DDRAM automatically through internal operation.

Output Register:

Output Register is used to read data from DDRAM and to check status data (busy
check). When the LCD is in active mode (CS1 and CS2 high), the Output register
can be selected by sending bits on RS and RW pins as shown in the following
table. When R/W and RS are high, data is latched into output register and when
R/W=H, RS=L, status data (busy check) can be read out.
The basic operation with graphical LCD requires following steps:

1. LCD Initialization

2. Page Selection

3. Column Selection

4. Data Display

All these steps have been explained in the following sections with corresponding
instruction sets.

1. LCD Initialization

Before displaying
anything on graphics LCD, it must be initialized, i.e., display must be put on and
column/page selection be made. This is achieved by giving proper instructions to
the LCD. To make Display On\Off the following set of instructions must be
followed in order:

a) Put these values in Data Register

Data appears when D=1 and disappears when D=0. When the display is off, there
is no effect on the data which is stored in DDRAM.

b) CS1=1, CS2=1(to activate display of both halves of LCD)

c) RS=0, R/W=0 (to select the instruction mode)

d) EN=1

e) Delay

f) EN=0 (to latch data into the input register)


Display on/off function can also be used to blink data continuously on the LCD by
switching the display with some delay.

2. Page selection

Before writing any data, the page of LCD must be selected. Page can be selected
through following steps:

a) Put these values in Data Register

Since there are a total of 8 pages (0–7), a particular page is selected by setting
three bits (X1-X3).

b) CS1=1, CS2=1(to activate display of both halves ofLCD)

c) RS=0, R/W=0 (to select the instruction mode)

d) EN=1

e) Delay

f) EN=0 (to latch data into the input register)

For example, if X3=0, X2=1 and X1=0, and then the second page is selected.
Reading or writing operation is done on this page until next page is set. Depending
on the column selection, the page is selected from either left or right half of the
graphics LCD.

3. Column selection

There are 128 [64 (=26) columns per half] in graphics LCD and they are

automatically incremented. This means that after selecting a column, it increases


on its own by one, after each write cycle.
So it is easier to write data column by column. A column can be chosen through
following instructions:

a) Put these values in Data Register

The corresponding controller (CS1 or CS2) is selected depending on the Column


number as shown below.

b) RS=0,
R/W=0

c) EN=1

d) Delay

e) EN=0 (to latch data into the input


register)

For example, if Page address is 0 and


Column address is 0, then 0th column
of page 0 is selected, i.e., the first
pixel will be selected.

4. Display data
After page and column selection, data can be sent to LCD for display. The
programming steps for display data are as given below:

a) Put the data values in Data Register. With every write cycle, data is written in
one column and the column then gets auto-incremented. A high data bit (DBx = 1)
corresponds to activated (dark) pixel and low data bit (DBx = 0) corresponds to
deactivated (light) pixel. Here MSB corresponds to 8th row in column and LSB to
1st row of column.

b) If column<63 then (CS1=1 & CS2=0) else (CS1=0 & CS2=1)

c) RS=1 and R/W=0 (to select write mode of LCD)

d) EN=1

e) Delay

f) EN=0 (to latch data into the input register)

If data port is given value ‘0x99’ or ‘10011001’ then column takes the values as
shown below.The following points can be included in above programming steps
for efficient programming:

1. While sending data to be written with array, one can specify the array limit as
well. This limit signifies the number of columns one wants to write at once. If the
limit is 8, eight columns will be written at once and if it is 7, seven columns will be
written in one go.

2. The condition ‘if (column >127)’ can be used to return the control back to the
main function if the limit exceeds the number of columns present in the LCD.

3. The function for setting column should be called again if array limit condition
doesn’t fit in left page and has to be extended to right page too.

4. Though column address increases itself by one but one variable shoul be taken
to check the conditions (ii) & (iii) explained above
Timing diagrams of glcd

Hardware used:
1. Lpc2148
2. 128*64 GLCD MODULE
Software used:
1. Keil uvision
2. Proteus
3. LCD assistant (for converting images into hex file)
Interface diagram:
Source code:
Source code consists of two program files: Main program file and one header file.
The header file is used to store the images data.

Main program:

#include<lpc21xx.h>

#include"image.h"

#define d0 1<<16
#define d1 1<<17

#define d2 1<<18

#define d3 1<<19

#define d4 1<<20

#define d5 1<<21

#define d6 1<<22

#define d7 1<<23

#define rs 1<<8

#define en 1<<12

#define cs1 1<<13

#define cs2 1<<14

#define rw 1<<15

#define totalpage 8

void delay(int k)

int a,b;

for(a=0;a<=k;a++)

for(b=0;b<100;b++);

void glcd_command(int command)

{
IO0CLR=(d0|d1|d2|d3|d4|d5|d6|d7);

command=command<<16;

IO0SET=command;

IO0CLR=rs;

IO0CLR=rw;

IO0SET=en;

delay(5);

IO0CLR=en;

void glcd_data(int data)

IO0CLR=(d0|d1|d2|d3|d4|d5|d6|d7);

data<<16;

IO0SET=data;

IO0SET=rs;

IO0CLR=rw;

IO0SET=en;

delay(5);

IO0CLR=en;

}
void glcd_init()

PINSEL0=0X00000000;

PINSEL1=0X00000000;

IO0DIR=(d0|d1|d2|d3|d4|d5|d6|d7|rs|rw|en|cs1|cs2);

IO0SET=(cs1|cs2);

delay(20);

glcd_command(0x3e);

glcd_command(0x40);

glcd_command(0xb8);

glcd_command(0xc0);

glcd_command(0x3f);

void glcd_clearall()

int column,page;

for(page=0;page<8;page++)

IO0SET=cs1;

IO0CLR=cs2;
glcd_command(0x40);

glcd_command((0xb8+page));

for(column=0;column<128;column++)

if(column=64)

IO0CLR=cs1;

IO0SET=cs2;

glcd_command(0x40);

glcd_command((0xb8+page));

glcd_data(0);

void glcd_string(const char *image)

int column,page;

for(page=0;page<8;page++)

{
IO0CLR=cs1;

IO0SET=cs2;

glcd_command(0x40);

glcd_command((0xb8+page));

for(column=0;column<128; columnist++)

if(column=64)

IO0SET=cs1;

IO0CLR=cs2;

glcd_command(0x40);

glcd_command((0xb8+page));

glcd_data(*image++);

int main()

glcd_init();

glcd_clearall();
glcd_string(img);

You might also like