Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can not read data from ks0108 lcd

Status
Not open for further replies.

abbas1707

Full Member level 4
Joined
May 3, 2007
Messages
216
Helped
20
Reputation
40
Reaction score
8
Trophy points
1,298
Activity points
2,371
read data from lcd

i was playing with ks0108 lcd on proteus using 89c51. i am able to write data,fonts and images to lcd . but i cant read data from display RAM.
here is code for reading data from lcd
Code:
Code:


#include <reg51.h>

sbit rs=P3^3;
sbit rw=P3^2;
sbit en=P3^1;
sbit cs1=P3^5;
sbit cs2=P3^4;

void delay()
{
   int k,l;
   for(k=0;k<3;k++)
      for(l=0;l<50;l++);
}
void sendCommand(unsigned char val)
{
   P1=val;
   rs=0;
   rw=0;
   en=1;
   en=0;
}
void sendByte(unsigned char dat)
{

   P1=dat;
   rs=1;
   rw=0;
   en=1;
   en=0;
}
void readByte()
{
   
   P1=0xff;
   rs=1;
   rw=1;
   delay();
   en=1;
   delay();
   en=0;
   P2=P1;
}

void main()
{
     while(1)
     {
      cs1=0;
      sendCommand(0x40);
      sendCommand(0xb8);
      sendByte(0xf4);
      sendCommand(0x40);
      sendCommand(0xb8);
      readByte();
      readByte();
   }
}

please help me solving this problem :cry::cry::cry:
 

read data from ks0108

well friend , i see a error in read routine in your program ,

try this logic :
**********************************************
p1=0xff;
rw = 1;
rs=1;
en = 1;
pause 2ms;
en = 0;

pause 2ms;

en = 1;
temp = port1;
pause 2ms;
en = 0;
value = temp;
*********************************
return;

and do tell me whenf it worked

Added after 11 minutes:

no need to call read byte two times !

Added after 2 minutes:

i think you misinterpreted datasheet , it says while reading a data byte , first the data from ram comes to buffer so you have to add en = 1 and en = 0 one more time to get it to port something like it . that makes it 2 times within 1 routine.
 

    abbas1707

    Points: 2
    Helpful Answer Positive Rating
lcd ks0108 cant read

gr8 jit_singh_tara!!!
Thanks for helping

i always sleep while reading data sheets:D:D:D:D
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top