ps_arunkumar
Member level 1
Hi all,
I am trying to interface to LCD with LPC2134. I have not seeing any output in the LCD. I followed the program posted and I tried to change the ports to 1 but its not working. Please tell me what I did wrong.
P1.16-->RS
P1.17-->En
P1.20 to P1.23--> Data pin 4 to 7
I am trying to interface to LCD with LPC2134. I have not seeing any output in the LCD. I followed the program posted and I tried to change the ports to 1 but its not working. Please tell me what I did wrong.
P1.16-->RS
P1.17-->En
P1.20 to P1.23--> Data pin 4 to 7
Code:
#include<lpc213x.h>
#include "lcd1.c"
int main()
{
IODIR1=0x00FF0000;
IOCLR1=0x00FF0000;
lcd_init();
cursor(1,5);
lcd_write("Test");
cursor(2,3);
lcd_write("program");
while(1);
}
Code:
#include <LPC213x.h>
#define lcd_delay 1000
void delay(int ms)
{
int i,n;
for (n=0; n<ms; n++)
{
for (i=0; i<lcd_delay; i++); /* For 1 ms */
}
}
void lcd_send_command(int command)
{
IOCLR1=0x00010000;
IOSET1=0x00020000;
IOSET1= (command & 0x00F00000);
IOCLR1=0x00020000;
delay(2);
IOCLR1=0x00F00000;
IOSET1=0x00020000;
IOSET1=((command & 0x000F0000)<<4);
IOCLR1=0x00020000;
delay(2);
IOCLR1=0x000F0000;
}
void lcd_send_data(int data)
{
IOSET1=0x00030000;
IOSET1=(data & 0x00F00000);
IOCLR1=0x00020000;
delay(2);
IOCLR1=0x00F00000;
IOSET1=0x00020000;
IOSET1=((data & 0x000F0000)<<4);
IOCLR1=0x00020000;
delay(2);
IOCLR1=0x000F0000;
}
void lcd_write(const char string[])
{
unsigned char x=0;
while(string[x]!='\0')
{
delay(2);
lcd_send_data(string[x]);
x++;
}
}
void cursor(int row, int column)
{
if(row==1)
{
lcd_send_command(0x00800000 +(column-1));
}
else if(row==2)
{
lcd_send_command(0x00C00000 + (column-1));
}
}
void lcd_init(void)
{
lcd_send_command(0x00020000);
lcd_send_command(0x00280000);
lcd_send_command(0x00060000);
lcd_send_command(0x00080000);
lcd_send_command(0x000C0000);
lcd_send_command(0x00010000);
delay(100);
}