Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 09, 2016, 06:45:33 06:45


Login with username, password and session length


Pages: [1]
Print
Author Topic: can not read data from ks0108 lcd  (Read 1659 times)
0 Members and 1 Guest are viewing this topic.
abbas1707
Junior Member
**
Offline Offline

Posts: 76

Thank You
-Given: 15
-Receive: 25



WWW
« on: January 15, 2008, 01:00:18 01:00 »

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:

#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
Logged

A Thousand Miles Journey Starts With a Single Step
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #1 on: January 15, 2008, 07:03:50 19:03 »

Hello abbas,

Try this,

Code:

// Using definitions from your code....

#define CON_LEFT    0
#define CON_RIGHT  1

unsigned char Ks_readbyte( unsigned char con )
{
  unsigned char rd_byte;

  rs = 1;               // we're not sending command
  P1 = 0xff;          // as input(float lines)
  rw = 1;              // we're reading

  // Assuming non-inverted CS
  if( con == CON_LEFT ) {  // reading from left controller
    cs1 = 1;        
    cs2 = 0;
  } else {                        // reading from right controller
    cs1 = 0;
    cs2 = 1;
  }

  en = 1;
  _nop_();
  rd_byte = P1;                // read while en=1 !
  en = 0;
 
  cs1 = cs2 = 0; // de-select both controllers
  P1 = 0x00;      // as output

  return rd_byte;
}

Hope you can work that out now. If you still have any problem, I can post isis sample.

BTW, how are able to put text, images on LCD when you're having problems with read  Huh
My code for putting pixel on LCD involves call to readbyte() function  Tongue
How did you managed to do that Huh

regards,
sam_des
Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
abbas1707
Junior Member
**
Offline Offline

Posts: 76

Thank You
-Given: 15
-Receive: 25



WWW
« Reply #2 on: January 15, 2008, 10:15:21 22:15 »

Thanx again. its working....
when we have to put text or image on blank lcd then there is no need of read()...thats y i was able to write text,images.
Anyway
now im going to make methods like
setPixel()
clearPixel()
goto(x,y)
etc...

Logged

A Thousand Miles Journey Starts With a Single Step
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #3 on: January 16, 2008, 06:42:07 18:42 »

Hello abbas,

Glad to hear that you got it working !

Quote
when we have to put text or image on blank lcd then there is no need of read()...thats y i was able to write text,images.
That's true. But we never know the contents of LCD on power-up. So it is safer to assume that it is not blank, unless we expilcitly do it.

BTW, I am posting a proteus sample for Ks0108 with 8051 as attchement.

regards,
sam_des
« Last Edit: January 16, 2008, 06:53:49 18:53 by sam_des » Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
cjq_sh
Newbie
*
Offline Offline

Posts: 11

Thank You
-Given: 1
-Receive: 1


« Reply #4 on: April 18, 2008, 02:05:38 14:05 »

Change the readByte() like this:
void readByte()
{
   P1=0xff;
   rs=1;
   rw=1;
   delay();
   en=1;
   delay();
   P2=P1;
   en=0;
  }
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC