Writ e a Embedded C code for
LCD Interface ARM Processor.
#include
<nxp/iolpc2148.h>
#define
LCD_EN 0X00000800
#define
RS
0X00000100
#define
DIOW 0X00000200
unsigned
char arr1[16]="Vi Microsystems ";
unsigned
char arr2[16]=" Chennai.. ";
void
delay_ms()
{
unsigned int i,j;
for(j=0;j<0xf;j++)
for(i=0;i<0xff;i++);
}
void
busy_check()
{
delay_ms();
}
void
command_write(int comm)
{
busy_check();
IO0CLR
= RS;
IO0CLR
= DIOW;
IO1PIN
= comm<<16;
IO0SET
= LCD_EN;
IO0CLR
= LCD_EN;
}
void
lcd_init()
{
command_write(0x38); // 5 * 7 Matrix
command_write(0x01); // Clear Display
command_write(0x0f); // Display ON and Cursor Blinking
command_write(0x86); // 5 * 7 Matrix
command_write(0x06);
}
void
lcd_out(unsigned char z)
{
busy_check();
IO0SET = RS; //RS = 1
IO0CLR = DIOW;
IO1PIN = (z<<16); //data with Rs=1
IO0SET = LCD_EN;
IO0CLR = LCD_EN;
}
void
main()
{
//--------------------Used Port
Lines--------------------------//
//LCD0-LCD7
- P1.16 to P1.23 //
//RS -
P0.8
//
//DIOW - P0.9
//
//LCDEN2 - P0.11 //
//-------------------------------------------------------------//
PINSEL2=0x00000000;
IO0DIR =0xffffffff; // RS, DIOW & LCDEN - Output Pins
IO1DIR =0xFFFFFFFF; // LCD0 to LCD7 - Output Pins
IO0DIR =0x5FFF7FFF;
IO1DIR =0xFFFFFFFF;
IO0CLR
= 0X00000800;
IO1PIN
= 0X00000000;
IO0PIN
= 0X00000000;
IO0CLR
= RS;
IO0CLR
= DIOW;
IO0CLR
= LCD_EN;
lcd_init();
command_write(0x80);
for(int i=0;i<16;i++)
lcd_out(arr1[i]);
command_write(0xC0);
for(int i=0;i<16;i++)
lcd_out(arr2[i]);
while(1);
}
0 comments:
Post a Comment