0% found this document useful (0 votes)
99 views7 pages

GLCD Interfacing with LPC2148

The document describes interfacing a graphics LCD with an LPC2148 microcontroller. It defines the LCD data and control pins connected to specific pins on the microcontroller. It includes functions to initialize the LCD, write commands and data to clear the display and write a string image to the LCD.

Uploaded by

kishan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views7 pages

GLCD Interfacing with LPC2148

The document describes interfacing a graphics LCD with an LPC2148 microcontroller. It defines the LCD data and control pins connected to specific pins on the microcontroller. It includes functions to initialize the LCD, write commands and data to clear the display and write a string image to the LCD.

Uploaded by

kishan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

/************************************************************

Program : Graphics LCD interfacing with LPC2148


-------------------------------------------------------------
P1.16-P1.31 =>LCD data lines
P1.16-RS,P1.17-EN,P1.18-CS1,P1.19-CS2,P1.20-RW
J8 connector to GLCD(PL1)
**************************************************************/
#include "lpc214x.h"
#include "Image.h"
#define LCD_D0 1<<24
#define LCD_D1 1<<25
#define LCD_D2 1<<26
#define LCD_D3 1<<27
#define LCD_D4 1<<28
#define LCD_D5 1<<29
#define LCD_D6 1<<30
#define LCD_D7 1<<31
#define RS (1<<16)
#define RW (1<<17)
#define EN (1<<18)
#define CS1 (1<<19)
#define CS2 (1<<20)
#define TotalPage 8
#define FOSC 12000000
void delay(int k) ;

voidGLCD_Command(int Command) /* GLCD command function


*/
{
IOCLR1= (LCD_D0|LCD_D1|LCD_D2|LCD_D3|LCD_D4|LCD_D5|
LCD_D6|LCD_D7);
Command = Command<<24;
IOSET1 = Command; /* Copy command on data pin */
IOCLR1 = RS; /* Make RS LOW to select command register */
IOCLR1 = RW; /* Make RW LOW to select write operation
*/
IOSET1 = EN;/* Make HIGH to LOW transition on Enable pin */
delay(5);
IOCLR1 = EN;
}

voidGLCD_Data(int Data) /* GLCD data function */


{
IOCLR1= (LCD_D0|LCD_D1|LCD_D2|LCD_D3|LCD_D4|LCD_D5|
LCD_D6|LCD_D7);
Data = Data << 24;
IOSET1 = Data; /* Copy data on data pin */
IOSET1 = RS; /* Make RS HIGH to select data register */
IOCLR1 = RW; /* Make RW LOW to select write operation */
IOSET1 = EN;/* Make HIGH to LOW transition on Enable pin */
delay(5);
IOCLR1 = EN;
}

voidGLCD_Init() /* GLCD initialize function */


{

PINSEL1=0x00000000;
IODIR1= (LCD_D0|LCD_D1|LCD_D2|LCD_D3|LCD_D4|LCD_D5|
LCD_D6|LCD_D7|RS|RW|EN|CS1|CS2);
/* Select both left & right half of display */
IOSET1 = (CS1 | CS2);
delay(20);
GLCD_Command(0x3E); /* Display OFF */
GLCD_Command(0x40); /* Set Y address
(column=0) */
GLCD_Command(0xB8); /* Set x address
(page=0) */
GLCD_Command(0xC0); /* Set z address (start line=0) */
GLCD_Command(0x3F); /* Display ON */
}

voidGLCD_ClearAll() /* GLCD all display clear


function */
{
intcolumn,page;

for(page=0;page<8;page++) /* Print 16 pages i.e. 8 page of each


half of display */
{
IOSET1 = CS1; /* If yes then change segment controller */
IOCLR1 = CS2;
GLCD_Command(0x40); /* Set Y address
(column=0) */
GLCD_Command((0xB8+page));/* Increment page address */
for(column=0;column<128;column++)
{
if (column == 64)
{
IOCLR1 = CS1; /* If yes then change segment
controller */
IOSET1 = CS2;
GLCD_Command(0x40); /* Set
Y address (column=0) */
GLCD_Command((0xB8+page));/* Increment page address */
}
GLCD_Data(0); /* Print 64 column of each
page */
}
}
}

voidGLCD_String(const char *image) /* GLCD string write function */


{
intcolumn,page;

for(page=0;page<8;page++) /* Print 16 pages i.e. 8 page of each


half of display */
{
IOSET1 = CS1; /* If yes then change segment controller */
IOCLR1 = CS2;
GLCD_Command(0x40); /* Set Y address
(column=0) */
GLCD_Command((0xB8+page));/* Increment page address */
for(column=0;column<128;column++)
{
if (column == 64)
{
IOCLR1 = CS1; /* If yes then change segment
controller */
IOSET1 = CS2;
GLCD_Command(0x40); /* Set
Y address (column=0) */
GLCD_Command((0xB8+page));/* Increment page address */
}
GLCD_Data(*image++); /* Print 64 column of
each page */
}
}
}
// LCD Delay Function
void delay(int k)
{
inta,b;
for(a=0;a<=k;a++)
for(b=0;b<100;b++);
}
int main(void)
{
VPBDIV = 0X01;
delay(1000);
GLCD_Init(); /* Initialize GLCD */
GLCD_ClearAll(); /* Clear all GLCD display */
GLCD_String(img); /* Display image on GLCD display
*/
while(1);
}

#include"lpc214x.h"

#ifndef _IMAGE_H
#define _IMAGE_H

constcharimg[1024] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xF0, 0xF8,
0xFC,
0xFC, 0xFE, 0xF8, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xF8,
0xFE,
0xFC, 0xFC, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x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C,
0x7C,
0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
0xF0,
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x60, 0x70, 0x38, 0x1C, 0x1E, 0x0F, 0x0F, 0x0F,
0x0F,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x3F, 0x7F,
0x7F,
0x7F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xC0,
0x00,

0x00, 0xFC, 0x7F, 0x3F, 0x0F, 0x07, 0x07, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06,
0x0C,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x03, 0x07, 0x0F,
0x1F,
};

#endif

You might also like