We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi when i tryed to interface the 16*2 lcd with lpc1248 i am facing problem i.e when i send 'A' to lcd it shows O in lcd display i attached my code beloe //////////////////////////////////////////////////////
// note my LCD data-line is P1.16 =D0 to P1.23 =D7 and control line is P0.11 =rs P0.12=rw and P0.13=e
#include<LPC214x.h>
void init_PLL(void);
void init_GPIO(void);
void lcd_data(unsigned char);
void lcd_cmd(unsigned char);
void lcd_init(void);
unsigned int adjust_portbit(unsigned char);
void delay(unsigned int);
#define E 0x00002000;
#define RW 0x00001000;
#define RS 0x00000800;
int main(void)
{
init_PLL();
init_GPIO();
lcd_init();
while(1)
lcd_data('A');
lcd_data('B');
lcd_data('c');
lcd_data('d');
delay(0xffffff);
}
void init_PLL(void)
PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK
PLL0CON=0x00000001;
PLL0FEED=0x000000AA;//UPDATE THE PLL REGISTER
PLL0FEED=0x00000055;
while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK IS GENERATED EXAXT VALUE,
PLL0CON=0x00000003; // CONNECT PLL
PLL0FEED=0x000000AA; //UPDATE THE PLL REGISTER
VPBDIV=0x00000002; //PCLK=1/2*CCLK
void init_GPIO( void)
//PINSEL0=0x00000000;
//PINSEL1=0x00000000;
IODIR0=0x0000FF00;
IODIR1=0x00FF0000;
void lcd_init(void)
lcd_cmd(0x30);
delay(0xffff);
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x01);
lcd_cmd(0x06);
//this routine is to tack the charecter and
move thet charecter to 16 to 23 bit position of port
because i am using 16 to 23 bit of port1 as a data
line in lcd ie p1.16 to d0 and p1.23 to d7 (8
bit lcd mode)
unsigned int adjust_portbit(unsigned char c)
unsigned char j;
unsigned int result;
result=c;
for(j=0;j<16;j++)
result=result<<1;
return result;
void lcd_data(unsigned char ldata)
unsigned int temp,z;
temp=adjust_portbit(ldata);
//init_GPIO();
z=~temp;
IOCLR1=z;
IOSET1=temp;
IOCLR0=RW;
IOSET0=RS;
IOSET0=E;
IOCLR0=E;
void lcd_cmd(unsigned char lcmd)
temp=adjust_portbit(lcmd);
IOCLR0=RS;
void delay(unsigned int value)
unsigned int i;
for(i=0;i<value;i++);
// for(j=0;j<0xffff;j++);
Did you read the instructions about how to post source code?
And why complain about lack of answers 38 minutes after the first post. Have you paid someone for premium support or why do you think volumteers have to jump whenever someone has a question?
hi Per Westermark i am not understand ur reply
When you make your next post, please read the comments written just above the box where you write your text.
See the note about source there?
This is way easier to read:
#include <stdio.h> int main(void) { printf("Hello World!\n"); return 0; }
instead of: #include <stdio.h>
int main(void) {
printf("Hello World!\n");
return 0;
sorry for my mistake note my LCD data-line is P1.16 =D0 to P1.23 =D7 and control line is P0.11 =rs P0.12=rw and P0.13=e #include<LPC214x.h> void init_PLL(void); void init_GPIO(void); void lcd_data(unsigned char); void lcd_cmd(unsigned char); void lcd_init(void); unsigned int adjust_portbit(unsigned char); void delay(unsigned int); //unsigned int E=0x00002000; //unsigned int RW=0x00001000; //unsigned int RS=0x00000800; #define E 0x00002000 #define RW 0x00001000 #define RS 0x00000800 int main(void) { //unsigned int temp; //unsigned int i; init_PLL(); init_GPIO(); lcd_init(); while(1) { lcd_data('A'); lcd_data('B'); lcd_data('c'); lcd_data('d'); delay(0xffffff); } } void init_PLL(void) { PLL0CFG=0x00000024; // TO GENERATE 60 MHZ CCLK PLL0CON=0x00000001; PLL0FEED=0x000000AA;//UPDATE THE PLL REGISTER PLL0FEED=0x00000055; while(!(PLL0STAT & 0x00000400)); // CHECK WHETHRT THE CCLK IS GENERATED EXAXT VALUE PLL0CON=0x00000003; // CONNECT PLL PLL0FEED=0x000000AA; //UPDATE THE PLL REGISTER PLL0FEED=0x00000055; VPBDIV=0x00000002; //PCLK=1/2*CCLK } void init_GPIO( void) { //PINSEL0=0x00000000; //PINSEL1=0x00000000; IODIR0=0x0000FF00; IODIR1=0x00FF0000; } void lcd_init(void) { lcd_cmd(0x30); delay(0xffff); lcd_cmd(0x30); delay(0xffff); lcd_cmd(0x30); delay(0xffff); lcd_cmd(0x38); delay(0xffffff); lcd_cmd(0x0e); delay(0xffff); lcd_cmd(0x01); delay(0xffffff); lcd_cmd(0x06); delay(0xffffff); } unsigned int adjust_portbit(unsigned char c) { unsigned char j; unsigned int result; result=c; for(j=0;j<16;j++) { result=result<<1; } return result; } void lcd_data(unsigned char ldata) { unsigned int temp,z; temp=adjust_portbit(ldata); //init_GPIO(); z=~temp; IOCLR1=z; IOSET1=temp; delay(0xffff); IOCLR0=RW; IOSET0=RS; IOSET0=E; delay(0xffffff); IOCLR0=E; } void lcd_cmd(unsigned char lcmd) { unsigned int temp,z; temp=adjust_portbit(lcmd); //init_GPIO(); z=~temp; IOCLR1=z; IOSET1=temp; delay(0xffff); IOCLR0=RW; IOCLR0=RS; IOSET0=E; delay(0xffffff); IOCLR0=E; } void delay(unsigned int value) { unsigned int i; for(i=0;i<value;i++); { // for(j=0;j<0xffff;j++); } }
1) Did you copy the source code directly from the text editor?
2) Are you _really_ indenting your code like that?
please man if you want help please help im beginer to arm and student
And as a student, it does help to early learn to indent the code. It will save you many, many, many hours looking for strange errors in the code.
Another thing: Have you verified that your delay actually makes a reasonable delay? Remember that a for loop that does not produce any side effect may be thrown away.
Instead of looping n turns, configure a timer and busy-loop looking at the timer counting. Then you will know exactly how many us or ms your delay will take.
unsigned int adjust_portbit(unsigned char c) { unsigned char j; unsigned int result; result=c; for (j=0; j<16; j++) { result=result<<1; } return result; }
Why not just:
return ((unsigned)c) << 16;
Have you designed your own hardware, or what board are you using?
thanks yes my own board
And how have you verified the hardware?
Yes
With such answers: Are you really expecting more help?
"Sanju naik K": Yes.
:-)
can i use slow GPIO in LCD interface
You can use either. It really doesn't matter, since the display does not have any requirement that you must be very fast when accessing it.
how to calculate 1 ms delay using arm lpc2148 mcu
Hello, I'm ok with you being busy and all but i need answer urgent Thanks.