hello everybody,
i need to interface LCD to PIC..
details are as under--
rs--portc0;
en--portc1;
data--portd;
the program tat i ve written (in embedded C using HT-PIC compiler) is as follows--
#include"pic1687x.h"
void cmd(unsigned char);
void datawrt(unsigned char);
void delay(void);
void initlcd(void);
static bit RS @ ((unsigned) & PORTC *8+0);
//static bit RW @ ((unsigned) & PORTC *8+1);
static bit EN @ ((unsigned) & PORTC *8+1);
//static bit SCK @ ((unsigned) & PORTC *8+3);
void initlcd()
{
unsigned char b[]={0x38,0x0c,0x01,0x80};
unsigned int c;
for(c=0;c<;c++)
cmd(b[c]);
}
void cmd(unsigned char y)
{
delay();
PORTD=y;
RS=0;
EN=1;
EN=0;
}
void datawrt(unsigned char x)
{
delay();
PORTD=x;
RS=1;
EN=1;
EN=0;
}
void delay()
{
/*EN=0;
RS=0;
TRISD=0x80;
RW=1;
EN=1;
EN=0;
while(BUSY !=0);
TRISD=0x00;*/
int f=0,g=0;
for(g=0xff;g!=0;g--)
for(f=0xff;f!=0;f--);
}
void main()
{
TRISD=0x00;
TRISC=0x00;
initlcd();
datawrt('1');
}
in the lcd, the first 5X7 blk is being selected & highlightened but no display of char..also, the lcd is working fine fr a pre-pgmed IC..
cd ne 1 plz help me out in dis regard...thanq in advance...
i need to interface LCD to PIC..
details are as under--
rs--portc0;
en--portc1;
data--portd;
the program tat i ve written (in embedded C using HT-PIC compiler) is as follows--
#include"pic1687x.h"
void cmd(unsigned char);
void datawrt(unsigned char);
void delay(void);
void initlcd(void);
static bit RS @ ((unsigned) & PORTC *8+0);
//static bit RW @ ((unsigned) & PORTC *8+1);
static bit EN @ ((unsigned) & PORTC *8+1);
//static bit SCK @ ((unsigned) & PORTC *8+3);
void initlcd()
{
unsigned char b[]={0x38,0x0c,0x01,0x80};
unsigned int c;
for(c=0;c<;c++)
cmd(b[c]);
}
void cmd(unsigned char y)
{
delay();
PORTD=y;
RS=0;
EN=1;
EN=0;
}
void datawrt(unsigned char x)
{
delay();
PORTD=x;
RS=1;
EN=1;
EN=0;
}
void delay()
{
/*EN=0;
RS=0;
TRISD=0x80;
RW=1;
EN=1;
EN=0;
while(BUSY !=0);
TRISD=0x00;*/
int f=0,g=0;
for(g=0xff;g!=0;g--)
for(f=0xff;f!=0;f--);
}
void main()
{
TRISD=0x00;
TRISC=0x00;
initlcd();
datawrt('1');
}
in the lcd, the first 5X7 blk is being selected & highlightened but no display of char..also, the lcd is working fine fr a pre-pgmed IC..
cd ne 1 plz help me out in dis regard...thanq in advance...