Home > Electronics > Part 3 – Getting started with a 128×64 Graphics LCD Display – Passing instructions

Part 3 – Getting started with a 128×64 Graphics LCD Display – Passing instructions

This part explains how to pass instructions/commands to the GLCD. On a high level, these are the steps:

  1. Select the GLCD half-section
  2. Put the Enable Pin LOW
  3. Put RS, RW and Data pins HIGH or LOW based on your command
  4. Put the Enable Pin HIGH
  5. Wait 2 milliseconds
  6. Put the Enable Pin LOW
  7. Wait 2 milliseconds
  8. GLCD responds

And you’re done! Easy-peasy!

Well, not quite. Let’s look into each of these steps in a little more detail. Here’s an image from the last part for quick reference:


clip_image002

  1. Select the GLCD half-section: As discussed in the previous part, to reach a particular pixel, we need to first select a half-section. The way this is done is by the Chip Select (CS) pins. There are 2 of these – CS1 and CS2. If CS1 is set then the instruction goes to the left half. If CS2 is set then it goes to the right half. If both are set, then the instruction goes to both.So, with this logic, we have the following combinations possible (Please note: For the JHD12864E, “setting” a pin or a register means taking it HIGH or 1 and “clearing” it means taking it LOW or setting it to 0. For some displays made by other manufacturers, “setting” means taking the pin LOW or 0 and vice versa for “clearing”. Always make sure this is clear otherwise it can cause a lot of grief later on):
  2. CS1 CS2 Result
    0 0 Nothing is selected, no instruction is received by either of the chips
    1 0 CS1 is set. So it receives the instruction
    0 1 CS2 is set. So it receives the instruction
    1 1 Both CS1 and CS2 are set. So, both will process the instruction
  3. Put the Enable Pin LOW – This step is necessary to ensure the Enable pin isn’t accidentally HIGH. When the state of the enable pin changes from LOW to HIGH, that’s when the display reads the instruction and acts on it when the Enable pin changes from HIGH to LOW again
  4. Put RS, RW and Data pins HIGH or LOW based on your command – Below, you can see the instruction set for various commands taken from the datasheet:
    clip_image004
    It’s a good thing that the GLCD has only 7 possible instructions. Makes our lives easier! But if you see this, you’ll realise that every instruction requires 10 bits – 1 for RS, 1 for RW and 8 for the actual data. Looking at this instruction set, it’s just a matter of making the corresponding pins HIGH or LOW before you make the enable pin HIGH
  5. Put the Enable Pin HIGH – After you’ve got the CS pins set, RS and RW set, the data pin set with the instruction code, you are now good to take the enable pin HIGH.
  6. Wait 2 milliseconds – The important thing to remember is that the KS0108 chips take some time to register the instruction. Hence this wait is important. If you look in the datasheet, you’ll see the following diagram:
    clip_image006
    The E cycle specifies a minimum of 1000 nanoseconds or 1microsecond for it to operate properly. Lots of forums suggest 2 “milliseconds” though which is quite a bit. In practice, I would suggest start with something like 4-5ms when you’re trying to set it up and then gradually reduce it once the display starts working. I’ve been able to bring the delay down to about 1microsecond and it still works quite well. The lesser the time, the faster the refresh rate.
  7. Put the Enable Pin LOW – Bring it down to LOW or 0 again to signal the end of the instruction
  8. Wait 2 milliseconds – Again, same reason as before. Give the GLCD time to react. I’ve been able to bring this down to 1 microsecond as well
  9. GLCD responds – Yay! It works!

Next: Part 4 – Getting started with a 128×64 Graphics LCD Display – Pin configuration

Prev: Part 2 – Getting started with a 128×64 Graphics LCD Display – Screen resolution and locating pixels

Table of Contents

About these ads
Categories: Electronics Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: