LCDInfo.com
http://forum.lcdinfo.com/

KS0108B Help please!
http://forum.lcdinfo.com/viewtopic.php?f=9&t=132
Page 1 of 1

Author:  Tim [ Mon Feb 10, 2003 3:54 ]
Post subject:  KS0108B Help please!

First, I've read almost every post in this group.

I'm interfacing a crystalfonts CFAG12864B unit to a PIC controller, I'll be ok if I can just get it off the ground. Can someone help me with what is required to initialize this display. What would help me the MOST would be some sort of suedo code like:

set cs1 high
wait 10ms
set D/I high
wait 5 ms
set data to databus 01110110
strobe E line etc, etc...

I've got the list of commands in the pdf file, it's the timing that has me thrown. Can anyone help, I'm really in a jam and this is important to me.

I'll post all my results for controlling with the PIC when finished.

Author:  Henri [ Mon Feb 10, 2003 15:50 ]
Post subject: 

I'm not sure if I have already posted this somewhere but anyway this is what I've used:

The WriteData and WriteCommand functions should show what is needed to write data and commands to the display.
Code:
#define DISPLAY_ON         0x3f  //0011 1111
#define DISPLAY_OFF        0x3e  //0011 1110
#define DISPLAY_STARTLINE  0xc0  //1100 0000
#define DISPLAY_PAGE_SET   0xb8  //1011 1000
#define DISPLAY_COLUMN_SET 0x40  //0100 0000

void cKS0108::WriteCommand(unsigned char Command, unsigned char CS)
{
  Delay(delay);

  SetPortVal(CONTROL, ENABLE_LO | CS | RS_LO, 1);
  SetPortVal(DATA, Command, 1);
  SetPortVal(CONTROL, ENABLE_HI | CS | RS_LO, 1);
  Delay(delay);
  SetPortVal(CONTROL, ENABLE_LO | CS | RS_LO, 1);

  //SetPortVal(DATA, 0, 1);
}

void cKS0108::WriteData(const unsigned char Data[], unsigned int amount)
{
 unsigned char cs;
 unsigned int counter;
 for (counter=0; counter < amount;counter++)
 {
    cs = CurrentColumn>63?CS2:CS1;

    Delay(delay);
    SetPortVal(CONTROL, ENABLE_LO | cs | RS_HI, 1);
    SetPortVal(DATA, Data[counter], 1);
    SetPortVal(CONTROL, ENABLE_HI | cs | RS_HI, 1);
    Delay(delay);
    SetPortVal(CONTROL, ENABLE_LO | cs | RS_HI, 1);

    CurrentColumn++;
    if (CurrentColumn > 127)
       return;
 }
}

void cKS0108::SetColumn(unsigned char y)
{
  CurrentColumn = y;
  if (y < 64)
  {
     WriteCommand(DISPLAY_COLUMN_SET | (y&63), CS1);
     WriteCommand(DISPLAY_COLUMN_SET | 0, CS2);
  } else
  {
     WriteCommand(DISPLAY_COLUMN_SET | 63, CS1);
     WriteCommand(DISPLAY_COLUMN_SET | ((y-64)&63), CS2);
  }
}

void cKS0108::SetPage(unsigned char x)
{
  Delay(delay);
  WriteCommand(DISPLAY_PAGE_SET | x, CS1);
  WriteCommand(DISPLAY_PAGE_SET | x, CS2);
}

void cKS0108::SetStartLine(unsigned char line)
{
  WriteCommand(DISPLAY_STARTLINE | (line & 63), CS1);
  WriteCommand(DISPLAY_STARTLINE | (line & 63), CS2);
}

void cKS0108::InitLCD()
{
  unsigned char value;
  int x, a;
  value = 0x0;

  WriteCommand(DISPLAY_ON, CS1);
  WriteCommand(DISPLAY_ON, CS1);
  SetStartLine(0);

  for (x=0;x < 8;x++)
    {
      SetPage(x);SetColumn(0);
      for (a = 0 ;a < 128; a++)
      WriteData(&value, 1);
    }
}

Author:  Henri [ Mon Feb 10, 2003 15:55 ]
Post subject: 

KS0108 timing:
Image

As you can see the timings in the code aren't exactly following the specs.

Author:  timhynde@lakeoriongroup.c [ Tue Feb 11, 2003 5:30 ]
Post subject: 

Thanks Henri:

Yes this will help, I found some other basic code. I can get 1/2 the display working both half work just not at the same time - I'll get it

Tnx again

Author:  phileo [ Tue Feb 25, 2003 7:14 ]
Post subject:  delay?

Hello,

I was wondering, how long does the delay need to be in between each write command?

I read somewhere in the driver that a delay of 30msec. is required. Is this correct ?


Thx.
Cheers,
Albert

Author:  Henri [ Tue Feb 25, 2003 9:24 ]
Post subject:  Re: delay?

phileo wrote:
Hello,
I was wondering, how long does the delay need to be in between each write command?

I don't know what the exact delay should be as the timings I'm using aren't exactly following the specs anyway. But the picture in the earlier post has the timings information from the datasheet.

The delay function I've used should measure the time in microseconds but knowing Windows I don't really know what the real accuracy is. I've just used the fastest timing that has worked.

Author:  Phileo [ Wed Feb 26, 2003 19:41 ]
Post subject: 

Hello Henri,

Thanks for your response.

I am using a CrystalFontz CFAG12864B-TMI-V graphical LCD.
I have code which can successfully clear the display, but I have problems trying to display characters on the screen.

For example, when I display the letter "A", only the left half of the A comes out.

I am wondering if I need to change the delays in between each data write to the LCD ?

Author:  Henri [ Wed Feb 26, 2003 22:03 ]
Post subject: 

Phileo wrote:
I am wondering if I need to change the delays in between each data write to the LCD ?

I noticed that for me a little delay was needed. But it was so little that using the delay function with value 0 worked.

Do you have any delay now ?

Author:  Phileo [ Fri Feb 28, 2003 10:07 ]
Post subject:  got it!

Hi Henri,

It turns out there was a bug with my code (I was using 16bit data type instead of 8bit data type for displaying characters).

I also did change the delays in between each write, and that improved the speed of the screen initialization

I can display a letter without problems now.


Thx.
Cheers,
Albert :D

Page 1 of 1 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/