LCD

Hay

I want interface 2x16 LCD with LPC2106 in 4 bit mode

I have tried the following code but I am not getting proper out put

Please Check the code.

#include"LPC210x.H"

#define RS_1 IOSET | 0x00000800 // RS=P0.11

#define RS_0 IOCLR | 0x00000800

#define EN_1 IOSET | 0x00000400 //EN=P0.10

#define EN_0 IOCLR | 0x00000400

// Data D4 D5 D6 D7 given to P0.16 P0.17 P0.18 P0.19

// R/W PIN IS CONNECTED TO GROUND

void delay()

{

unsigned int i;

for(i=0;i<=20000;i++);

}

void lcdcmd(unsigned char value) // LCD COMMAND

{

int data,copy;

data=value;

data=data<<16;

copy=data;

data=((data>>4)& 0x000F0000); //Strobe 4-Bit High Nibble to LCD

IOSET=IOSET | data;

IOCLR=IOCLR |~data;

IOCLR=RS_0; //COMMAND REGISTER

IOSET=EN_1;//LCD TO LATCH THE DATA

delay();

IOCLR=EN_0;

//lower nibble

data=copy;

data=(data & 0x000F0000); // Strobe 4-Bit Low -Nibble to LCD

IOSET=IOSET | data;

IOCLR=IOCLR |~data;

IOCLR=RS_0;//COMMAND REGISTER

IOSET=EN_1;//LCD TO LATCH THE DATA

delay();

IOCLR=EN_0;

}

void lcddata(unsigned char value) // LCD DATA

{

int data,copy;

data=value;

data=data<<16;

copy=data;

data=((data>>4) & 0x000F0000); //Strobe 4-Bit High Nibble to LCD

IOSET=IOSET | data;

IOCLR=IOCLR |~data;

IOSET=RS_1;//DATA REGISTER

IOSET=EN_1;//LCD TO LATCH THE DATA

delay();

IOCLR=EN_0;

////lower nibble/////////////////

data=copy;

data=(data & 0x000F0000); //Strobe 4-Bit Low Nibble to LCD

IOSET=IOSET | data;

IOCLR=IOCLR |~data;

IOSET=RS_1;//DATA REGISTER

IOSET=EN_1;;//LCD TO LATCH THE DATA

delay();

IOCLR=EN_0;

}

void main()

{

PINSEL0=0x00000000; //ALL PINS ARE GPIO

PINSEL1=0x00000000;

IODIR=0xFFFFFFFF; // ALL PINS ARE OUTPUT

delay();

lcdcmd(0x28); // 2X16 LCD IN 4 BIT MODE

lcdcmd(0x0E);

lcdcmd(0x01);

lcdcmd(0x06);

lcdcmd(0x80);

lcddata(‘T’);

lcddata(‘H’);

lcddata(‘A’);

lcddata(‘N’);

lcddata(‘K’);

lcddata(‘S’);

while(1);

}

Regards

chandu

Is your delay long enough?

You’ll find some LCD code in the LPC2000 group’s files section.

Leon

hay

Please help me any body regarding the 2x16 LCD in 4 bit mode data interfacing with LPC2106

I am straggling with the above code, I have executed above code. when ever I switched ON the system

Data is not displaying on the LCD, when ever I press reset button at that time data is displaying on the LCD

Please give me some solution

Regards

chandu

This could help. The initialization code is critical or the display does not switch in 4bits mode.

Source:

http://chibios.svn.sourceforge.net/view … iew=markup

Header file:

http://chibios.svn.sourceforge.net/view … iew=markup

I use this code for ad 2x16 display attached to an AVR micro in 4 bit mode, changing just the code for the I/O ports it should work for any micro, where you see chThdSleep() just insert a delay in milliseconds.

Note that the port is used in output mode only to make things easier, it works just fine.

regards,

Giovanni