Beruflich Dokumente
Kultur Dokumente
AIM:
To develop a program to display the image in graphical LCD using LPC2129.
ALGORITHM:
1. Initialize the header files
2. Define the GLCD control signals such as RS, DIOW, EN, and CS.
3. Select an image and obtain the pixel codes of the image through the GLCD editor file.
4. Initialize the ports for RS and DIOW pins.
i. RS -> P0.11
ii. DIOW -> P1.21
5. In write function, set the value to register select pin and clear the values of DIOW pins to
write the image.
6. Write function is performed for both the chip selects (CS1&CS2).
7. The main function of GLCD is called to initialize all the command signals.
8. Initialize the pins and assign it as input and output.
9. The main program runs inside the while loop to continue the steps to obtain the whole
image.
10. Given image is displayed in the GLCD screen.
SAMPLE CODE:
#include <nxp\iolpc2129.h>
#include <stdio.h>
#define BAUD 19200
#define LCD_EN 0X00008000 // en
-> P0.15
-> P1.18
#define RS
#define DIOW
0X00000800 // RS
-> P0.11
#define CS1
0x00020000 // CS1
-> P1.17
#define CS2
0x00010000 // CS2
-> P1.16
// D0 to D7 ->P0.16 to P0.23
unsigned char const house_bmp[1024]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,192,224,112,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176, 96,224,128, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 3, 35, 49, 49, 49,
49, 49, 49, 49, 51, 3,199,255,127, 31, 31, 15, 7, 7, 3, 3,
3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 7, 7, 15,
15, 31,127,255,255,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 7, 6, 6, 14, 30,
30, 30, 30, 30,254,255,255, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,252,255,255,255,254, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 7,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 17, 51, 3, 3, 15,
7, 3, 3, 17,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,129,129,129,129,128,128,128,128,128,128,128,128,
128,128,128,128,128,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 98,127,111, 99, 99,
99, 99, 99, 99,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,255,255,255,255,255,255, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 8,140,140,140,140,
140,140,140,140,141,159,255,240,192, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 7, 31, 63, 31, 31, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0,128,192,248,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,127,255,128,127,127,127,112,113,113,113,113,
113,113,113,113,113,113,113,113,115,119,126,124,124,120,120,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,120,120,124,
126,127,127,127,127,127,127,127, 63,192,255,127, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0
};
char ch1[]={0X00,0X7E, 0X11, 0X11, 0X11, 0X7E }; // A
static void delay_ms()
{
volatile int i,j;
for (i=0;i<0X0F;i++)
for (j=0;j<50;j++);
}
void busy_check()
{
delay_ms();
IO0CLR = RS;
IO1CLR = DIOW;
}
void writedata(unsigned int ch5)
{
busy_check();
IO0SET = RS;
IO1CLR = DIOW;
ch5= ch5 << 16;
IO0SET = ch5 ;
IO0SET = LCD_EN;
IO1SET = LCD_EN1;
IO0CLR = LCD_EN;
IO1CLR = LCD_EN1;
IO0CLR =ch5;
}
void write_house1(unsigned int cs,unsigned int col)
{
int i;
IO1SET = CS2;
//PAGE 2 IS SELECGTED
IO1CLR = CS1;
//PAGE 1 IS DISABLE.
for(i=col;i<(64 +col);i++)
writedata(house_bmp[i]);
}
void write_house(unsigned int cs,unsigned int col)
{
int i;
IO1SET = CS1;
IO1CLR =CS2;
for(i=col;i<(64+col);i++)
writedata(house_bmp[i]);
}
void writecmd(unsigned int G_lcd)
// PAGE 2 IS DISABLE.
{
busy_check();
IO0CLR = RS;
// RS (P1.21)->clear.
//
while(1);
}
void pageclear()
{
int i,y;
IO1SET = CS1 | CS2;
for(i=0xb8;i<0xc0;i++)
{
writecmd(i);
// Select Pages.
writecmd(0x40);
for (y=0;y<64;y++)
writedata(0x0);
}
}
void clear_display()
{
pageclear();
}
void glcd_init()
{
writecmd(0x3e);
writecmd(0x3f);
writecmd(0xc0)
writecmd(0xb8);
}
void main ()
{
int page,dat;
PINSEL0=0x00000000;
PINSEL1=0x00000000;
PINSEL2=0x00000000;
IO0DIR = 0XFFFFfFFF;
IO1DIR = 0XFFFFFFFF;
IO0SET = 0x00003000;
glcd_init();
clear_display();
for(page =0;page<8;page++)
{
dat = page * 128 ;
writecmd(0xB8+page);
writecmd(0x40);
write_house(0x40000000,dat);
writecmd(0xB8+page);
writecmd(0x40);
write_house1(0x80000000,dat + 64);
}
while(1);
}
OUTPUT:
Snapshot of the GLCD screen:
RESULT:
Thus the program is coded to display the selected image in the GLCD screen using LPC
2129.