Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/08/01 07:24
Read: times


 
#12296 - RE: problem with 4x20 lcd.
Hello Jacek! Thanks for the answer.
My display working properly on lines 1 and 3.
KS0066 this is samsung analog of the HD driver.

I use keil c for frogramming at89s8252.

This is my init function. According to the manual.
void init_lcd()
{
delay(200mks);
DATA=0x020;
EN=TRUE;
EN=FALSE;
delay(2mks);
DATA=0x020;
EN=TRUE;
EN=FALSE;
delay(2mks);
lcdWriteCommand(0x028);
//wait_lcd();
delay(50mks);

lcdWriteCommand(0x08);
delay(2ms);
lcdWriteCommand(0x0C);
delay(2ms);
lcdWriteCommand(0x01);
delay(2ms);



lcdWriteCommand(0x06);
delay(10mks);

This is write command function for the 4bit mode.

void lcdWriteCommand(unsigned int db)
{
int hi,lo;
delay(2 mks);
hi=db&0x0F0;
lo=((db|0x0f0)^0x0F0)<<4;
DATA=DATA|0x0F0;
DATA=DATA&(hi|0x0F);
RS=FALSE;
EN=TRUE;
EN=FALSE;

DATA=DATA|0x0F0;
DATA=DATA&(lo|0x0F);
RS=FALSE;
EN=TRUE;
EN=FALSE;
}

This is write data function for 4bit.
void lcdWriteData(unsigned int db)
{
int hi,lo;
delay(2 mks);
hi=db&0x0F0;
lo=((db|0x0f0)^0x0F0)<<4;
DATA=DATA|0x0F0;
DATA=DATA&(hi|0x0F);
RS=TRUE;
EN=TRUE;
EN=FALSE;

DATA=DATA|0x0F0;
DATA=DATA&(lo|0x0F);
RS=TRUE;
EN=TRUE;
EN=FALSE;
}

void write_char(unsigned char ch)
{
delay(1 mks);
lcdWriteData(ch); /*MOV DATA,A*/
//wait_lcd(); /*LCALL WAIT_LCD*/

}

This function writes text at the specified position :
void write_CRSRstring(char *txtstring, int x, int y)
{
int adr;
int i;
if (y==1) adr=0x080+x-1;
if (y==2) adr=0x0C0+x-1;
if (y==3) adr=0x094+x-1;
if (y==4) adr=0x0D4+x-1;
lcdWriteCommand(adr);
delay(30mks);


for(i=0;txtstring[i]!=0x00;i++)
{
if (txtstring[i]!=0x00) write_char(txtstring[i]);

}
}
This is text fuction.
main{
write_CRSRstring("Hello1",10,1);
write_CRSRstring("Hello2",1,2);
write_CRSRstring("Hello3",5,3);
write_CRSRstring("Hello4",15,4);
while(1);
}

As you can see all fuctions looks correct. I have successfully used them for the 2-lines display.

Any ideas?

Thanks for the assistance!
Igor

List of 14 messages in thread
TopicAuthorDate
problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: for Jacek            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      
RE: problem with 4x20 lcd.            01/01/70 00:00      

Back to Subject List