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 i am trying to interface an 16x2 lcd onto an arm7 board lpc2148. the pins i am using for the data is p0.16-p0.23 and for control signals ie rs rw e i am using p1.24 p1.25 p1.26 respectively.When i dump the following code nothing is getting changed in the display .can anybody help me out...i am attaching the code here ..kindly do the needful
#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); void delay(unsigned int);
#define E 0x04000000 #define RW 0x02000000 #define RS 0x01000000
int main(void) { init_PLL(); init_GPIO(); lcd_init(); while(1) { lcd_data('A'); lcd_data('B'); lcd_data(96); 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=0x00FF0000; PINSEL1=0x07000000; IODIR0=0x00FF0000; IODIR1=0x07000000; } void lcd_init(void) {
lcd_cmd(0x380000); delay(0xffffff); lcd_cmd(0x0e0000); delay(0xffffff); lcd_cmd(0x800000); delay(0xffffff); lcd_cmd(0x060000); 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; IOSET0=ldata; delay(0xffffff); IOCLR1=RW; IOSET1=RS; delay(0xffffff); IOSET1=E; delay(0xffffff); IOCLR1=E; } void lcd_cmd(unsigned char lcmd) {
unsigned int temp,z; temp=adjust_portbit(lcmd); init_GPIO(); z=~temp; IOCLR1=z; IOSET0=lcmd; delay(0xffffff); IOCLR1=RW; IOCLR1=RS; IOSET1=E; delay(0xffffff); IOCLR1=E;
} void delay(unsigned int value) { unsigned int i; for(i=0;i<value;i++); {
} }
Corrected Post here: http://www.keil.com/forum/docs/thread14875.asp
(next time, make the correction as a reply in the same thread - don't start a new one!)
#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); void delay(unsigned int); #define E 0x04000000 #define RW 0x02000000 #define RS 0x01000000 int main(void) { init_PLL(); init_GPIO(); lcd_init(); while(1) { lcd_data('A'); lcd_data('B'); lcd_data(96); 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=0x00FF0000; PINSEL1=0x07000000; IODIR0=0x00FF0000; IODIR1=0x07000000; } void lcd_init(void) { lcd_cmd(0x380000); delay(0xffffff); lcd_cmd(0x0e0000); delay(0xffffff); lcd_cmd(0x800000); delay(0xffffff); lcd_cmd(0x060000); 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; IOSET0=ldata; delay(0xffffff); IOCLR1=RW; IOSET1=RS; delay(0xffffff); IOSET1=E; delay(0xffffff); IOCLR1=E; } void lcd_cmd(unsigned char lcmd) { unsigned int temp,z; temp=adjust_portbit(lcmd); init_GPIO(); z=~temp; IOCLR1=z; IOSET0=lcmd; delay(0xffffff); IOCLR1=RW; IOCLR1=RS; IOSET1=E; delay(0xffffff); IOCLR1=E; } void delay(unsigned int value) { unsigned int i; for(i=0;i<value;i++); { } }
I said next time!
you've already started the duplicate thread, so what's the point in continuing this one?!
Rather than just re-post the same code, why not spend some time commenting it?
There's a high chance that will lead you to your own problem - see: www.8052.com/.../164650
and don't write in ALL CAPITALS - it just makes the text much harder to read.
For ease of reading, lay it out neatly & carefully.
Think about how a bit of whitespace could help...
See: www.8052.com/.../165484
is there any solution to the problem tat i am in....ie regarding the lcd code
yes.
Of course there is!
It involves you carefully studying the Datasheets for both the processor and the LCD to see what your code needs to do.
Then examine the source code carefully to see if it actually does what it needs to do - this is where commenting as you go will help you.
If the source code seems right, then start debugging - maybe in the simulator, or get an oscilloscope on your real hardware.