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++);
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.
Initialize a free-running timer with suitable frequency - for example 1kHz or 1MHz.
Then create a busy loop that samples the timer until the required time has passed.
Or create interrupt handler.
init_timer0(void) { T0TR= (PCLK/1000000)-1; // Prescaled to 1MHz-> 1us T0TCR = 1; } void delay(unsigned us) { now = T0TC; while ((T0TC - now) < delay) ; }
By the way - shouldn't you urgently spend time reading datasheets or look at the NXP-supplied reference code? Or will you learn too fast then?
Per, Hello, I'm ok with you being busy
Do you think this guy confused a busy loop with "being busy" ?
=:0
"please man if you want help please help im beginer to arm and student"
I mainly think that he has a confused view of the word "student", and its relation to studying.