Interfacing LCD with
LPC2148 ARMLCD (Liquid Crystal Display)
Liquid Crystal Display also called as LCD is very helpful
in providing user interface as well as for debugging purpose.
A liquid crystal display (LCD) is a flat panel display that uses
the light modulating properties of liquid crystals (LCs). LCD
Modules can present textual information to user.nterfacing LCD
Fig. 1 shows how to interface the LCD to
microcontroller. The 2x16 character LCD interface card with
supports both modes 4-bit and 8-bit interface, and also
facility to adjust contrast through trim pot. In 4-bit interface
7 lines needed to create 4-bit interface; 4 data bits (DO —
D3), three control lines, address bit (RS), read/write bit
(R/W) and control signal (E).
2 Line X 16 Charecter
Microcontroller
port lines
LCD Display
Fig. 1 Interfacing 4 bit LCD to MicrocontrollerInterfacing 4 bit LCD with LPC2148
We now want to display a text in LPC2148 Primer Board
by using 4 bit LCD module.
The ARM7 LPC2148 Primer board has seven numbers of
LCD connections are needed to create 4-bit interface;
connected with 4 data bits (PO.19 — P0.22, D4-D7), address
bit (RS-P0.16), read/write bit (R/W-PO.17) and control signal
(E-P0.18) to make LCD display.Pin Assignment with LPC2148
(%) Make switch Sw28 to ‘LED’
‘=F [abel marking position1 0x01 Clear Display Screen
2 0x30 Function Set: 8-bit, 1 Line, 5x7 Dots
3 0x38 Function Set: 8-bit, 2 Line, 5x7 Dots
4 0x20 Function Set: 4-bit, 1 Line, 5x7 Dots
5 0x28 Function Set: 4-bit, 2 Line, 5x7 Dots.
6 0x06. Entry Mode
7 0x08 Display off, Cursor off
8 Ox0E Display on, Cursor on
9 Ox0C Display on, Cursor off
10 Ox0F Display on, Cursor blinking
1i 0xi8 Shift entire display left
12 OxiC Shift entire display right
13 0x10 Move cursor left by one character
14 Oxi4 Move cursor right by one character
15 0x80 Force cursor to beginning of 1st row
16 Oxco Force cursor to beginning of 2nd rowCircuit Diagram to Interface 4 bit LCD with LPC2148
sarsaze=finglude _//Includes LPC2148 register definitions
define DATA PORT() 1O0SET=(1<<16) //Function to select data por on LCD
define READ DATA() 100SET=(1<<17) //Function to select read
operation on LCD
foefine EN HI() IOOSET=(1<<12) //Fanction to Enable LCD
define COMMAND FORT|) IOOCLR=(1<<16) //Function to select command pert cn ICD
define WRITE_DAIA() IOOCLR=(1<<17) //Function to select write operation on LCD
eefine EN_LOW() TOOCLA=, //Function to disable LCD
")
")
unsigned char String1 (16
ungigned char String? (16
void Delay(unsigned char 3)
t
unsigned int i:
fon(73>0:3--)
{
for|i=0: 4<60000; i++):
¥
}
void Delay, Smal} (unsigned char 3)
¢
ungigned int i;
f05(3>003--)
€
EoEjar0r E1000; a+);
¥
}Yoig LED Command (unsigned int data) //This function is used to send ICD commands
€
unsigned int temp=0;
EN_LOW() =
COMMAND PORT)
WRITE_DAIA()?
peLay(2o) +
Heid LCD Data (unsigned int data) —//This function is used to send data to LCD
t
unsigned int temp=0;
EN_LOW() :DATA_PQRT :
WRITE BATA -
kemprdata:
EO0PiNe-OxFFa7FFFF;
IOOPIN|={(temp & OxFO) << 15;
EN_BEQ +:
EN_EGW()
Rempadeaca « oxor.
TOOPINS=OxFFS7FFFF.
TOOPIN|={temp) << 19;
EN_BEQ +:
=N_EGWO)
Relax Smalh(2:
¥
woid Lep Inara
<
EGR_Commang (0x20) 7
ECD Command (0x28)
ECD Command (0x0c)
EGD Command (0x06) 7
*
woid LCD String (unsioned char *data)
sa
while (*data)
¢
LOD Dava(*daca);
aabatt?
+
+int main (void)
{
PINSELO
PINSELL
PINSEL2 = 0x00000000;
Delay(20
TOODIR = (1<<22) | (1<<21) | (1¢<20) | (1<<19) | (1<<18) | (1<<17) | (1<<16)7
/f Set PO.16, PO.17, PO.18, PO.19, PO.20, PO.21, P0.22 a8 Output
// Snable GPIO on all pins
ED Init (0;
ECD Command (0x01);
Delay (20):
LCD. Command (0x80):
LCD String(eStringl[0]);
ECD. Command (oxco) :
LCD string eString2 [0]) +:
while@)
{
t