|
|
View previous topic :: View next topic |
Author |
Message |
MMurray
Joined: 19 Feb 2011 Posts: 22
|
Glcd driver for 192 x 64 using KS0108b |
Posted: Sat Feb 19, 2011 3:54 pm |
|
|
Can anyone lead me to a driver for a 192 x 64 glcd display using 3 chip selects? I am a noob and do not know where I should be looking!
Thanks
Matt |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Feb 19, 2011 6:54 pm |
|
|
This is a CCS driver for a 128x64 KS0108 LCD:
Quote: |
c:\program files\picc\drivers\hdm64gs12.c
|
You could possibly modify it to add one more 64x64 section. You might
want to test it, and see if you can make it work with 2/3rds of your LCD. |
|
|
MMurray
Joined: 19 Feb 2011 Posts: 22
|
|
Posted: Sat Feb 19, 2011 7:30 pm |
|
|
Thank you, I have tried that driver and it does work. I have also turned off the CS3 by grounding that line and it clears that section of the glcd.
I have looked over this driver and I am not sure of how I could modify it to handle the third section. Any advice would be welocome. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Feb 19, 2011 8:49 pm |
|
|
Post the manufacturer and model number of your LCD, and post a link
to the web page for it. Post a link to the data sheet for the LCD.
Post your PIC and compiler version.
If the LCD is mounted on a board and you bought the board, then post
a link to the board's web page.
In other words, post all the info. |
|
|
MMurray
Joined: 19 Feb 2011 Posts: 22
|
|
Posted: Sun Feb 20, 2011 10:52 am |
|
|
Thanks PCM Programmer.
I took your advice and re-wrote the driver for the third section. Works great! |
|
|
albe01
Joined: 02 Jul 2010 Posts: 30 Location: italy
|
|
Posted: Sat Apr 09, 2011 2:40 pm |
|
|
hello to everyone, where i can find the modified driver to this glcd? i have some 192x64 glcd and i'd like use it
regards |
|
|
MMurray
Joined: 19 Feb 2011 Posts: 22
|
192 x 64 driver |
Posted: Wed Apr 13, 2011 11:17 am |
|
|
Enjoy.
Code: |
/////////////////////////////////////////////////////////////////////////
//// HDM64GS192.c ////
//// ////
//// This file has been modified to handle the 192 x 64 display ////
//// ////
//// ////
//// This file contains drivers for using a Hantronix HDM64GS12 with ////
//// a KS0108 display controller. The HDM64GS12 is 128 by 64 pixels. ////
//// The driver treats the upper left pixel as (0,0). ////
//// ////
//// Use #define FAST_GLCD if the target chip has at least 1k of RAM ////
//// to decrease the time it takes to update the display. ////
//// glcd_update() must then be called to update the display after ////
//// changing the pixel information. ////
//// See ex_glcd.c for suggested usage. ////
//// See KS0108.c for controlling a single 64 by 64 display ////
/////////////////////////////////////////////////////////////////////////
//// ////
//// LCD Pin connections: ////
//// (These can be changed as needed in the following defines). ////
//// * 1: VSS is connected to GND ////
//// * 2: VDD is connected to +5V ////
//// * 3: V0 - LCD operating voltage (Constrast adjustment) ////
//// * 4: D/I - Data or Instruction is connected to B2 ////
//// * 5: R/W - Read or Write is connected to B4 ////
//// * 6: Enable is connected to B5 ////
//// *7-14: Data Bus 0 to 7 is connected to port d ////
//// *15: Chip Select 1 is connected to B0 ////
//// *16: Chip Select 2 is connected to B1 ////
//// *17: Reset is connected to C0 ////
//// *18: Negative voltage is also connected to the 20k Ohm POT ////
//// *19: Positive voltage for LED backlight is connected to +5V ////
//// *20: Negavtive voltage for LED backlight is connected to GND ////
//// ////
/////////////////////////////////////////////////////////////////////////
//// ////
//// glcd_init(mode) ////
//// * Must be called before any other function. ////
//// - mode can be ON or OFF to turn the LCD on or off ////
//// ////
//// glcd_pixel(x,y,color) ////
//// * Sets the pixel to the given color. ////
//// - color can be ON or OFF ////
//// ////
//// glcd_fillScreen(color) ////
//// * Fills the entire LCD with the given color. ////
//// - color can be ON or OFF ////
//// ////
//// glcd_update() ////
//// * Write the display data stored in RAM to the LCD ////
//// * Only available if FAST_GLCD is defined ////
//// ////
/////////////////////////////////////////////////////////////////////////
//// (C) Copyright 1996, 2004 Custom Computer Services ////
//// This source code may only be used by licensed users of the CCS ////
//// C compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, ////
//// reproduction or distribution is permitted without written ////
//// permission. Derivative programs created using this software ////
//// in object code form are not restricted in any way. ////
/////////////////////////////////////////////////////////////////////////
#ifndef HDM64GS12
#define HDM64GS12
#ifndef GLCD_WIDTH
#define GLCD_WIDTH 192
#endif
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_B0 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_B1 // Chip Selection 2
#endif
#ifndef GLCD_CS3
#define GLCD_CS3 PIN_B6 // Chip Selection 2
#endif
#ifndef GLCD_DI
#define GLCD_DI PIN_B2 // Data or Instruction input
#endif
#ifndef GLCD_RW
#define GLCD_RW PIN_B4 // Read/Write
#endif
#ifndef GLCD_E
#define GLCD_E PIN_B5 // Enable
#endif
#ifndef GLCD_RST
#define GLCD_RST PIN_C0 // Reset
#endif
#define GLCD_LEFT 0
#define GLCD_MID 1
#define GLCD_RIGHT 2
#ifndef ON
#define ON 1
#endif
#ifndef OFF
#define OFF 0
#endif
/////////////////////////////////////////////////////////////////////////
// Function Prototypes
/////////////////////////////////////////////////////////////////////////
void glcd_init(int1 mode);
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 color);
void glcd_fillScreen(int1 color);
void glcd_writeByte(int side, BYTE data);
BYTE glcd_readByte(int side);
void glcd_update();
/////////////////////////////////////////////////////////////////////////
#ifdef FAST_GLCD
struct
{
unsigned int8 left[512];
unsigned int8 right[512];
unsigned int8 mid[512];
} displayData;
#endif
//=============================================================================
// Purpose: Initialize the LCD.
// Call before using any other LCD function.
// Inputs: OFF - Turns the LCD off
// ON - Turns the LCD on
void glcd_init(int1 mode)
{
// Initialze some pins
output_high(GLCD_RST);
output_low(GLCD_E);
output_low(GLCD_CS1);
output_low(GLCD_CS2);
output_low(GLCD_CS3);
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0xC0); // Specify first RAM line at the top
glcd_writeByte(GLCD_RIGHT, 0xC0); // of the screen
glcd_writeByte(GLCD_MID, 0xC0);
glcd_writeByte(GLCD_LEFT, 0x40); // Set the column address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_MID, 0x40);
glcd_writeByte(GLCD_LEFT, 0xB8); // Set the page address to 0
glcd_writeByte(GLCD_RIGHT, 0xB8);
glcd_writeByte(GLCD_MID, 0xB8);
if(mode == ON)
{
glcd_writeByte(GLCD_LEFT, 0x3F); // Turn the display on
glcd_writeByte(GLCD_MID, 0x3F);
glcd_writeByte(GLCD_RIGHT, 0x3F);
}
else
{
glcd_writeByte(GLCD_LEFT, 0x3E); // Turn the display off
glcd_writeByte(GLCD_MID, 0x3E);
glcd_writeByte(GLCD_RIGHT, 0x3E);
}
glcd_fillScreen(OFF); // Clear the display
#ifdef FAST_GLCD
glcd_update();
#endif
}
//==================================================================================
// Purpose: Update the LCD with data from the display arrays
#ifdef FAST_GLCD
void glcd_update()
{
unsigned int8 i, j;
unsigned int8 *p1, *p2, *p3;
p1 = displayData.left;
p2 = displayData.right;
p3 = displayData.mid
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0x40); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0x40);
glcd_writeByte(GLCD_MID, 0x40);
glcd_writeByte(GLCD_LEFT, i | 0xB8); // Set page address
glcd_writeByte(GLCD_RIGHT, i | 0xB8);
glcd_writeByte(GLCD_MID, i | 0xB8);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT, *p1++); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, *p2++); // Turn pixels on or off
glcd_writeByte(GLCD_MID, *p3++); // Turn pixels on or off
}
}
}
#endif
//===================================================================================
// Purpose: Turn a pixel on a graphic LCD on or off
// Inputs: 1) x - the x coordinate of the pixel
// 2) y - the y coordinate of the pixel
// 3) color - ON or OFF
void glcd_pixel(unsigned int8 x, unsigned int8 y, int1 color)
#ifdef FAST_GLCD
{
unsigned int8* p;
unsigned int16 temp;
temp = y/8;
temp *= 64;
temp += x;
if((x > 63)&&(x<128))
{
p = displayData.mid + temp - 64;
}
else if(x>127)
{
p = displayData.right + temp-128;
}
else
{
p = displayData.left+temp;
if(color)
{
bit_set(*p, y%8);
}
else
{
bit_clear(*p, y%8);
}
}
#else
{
BYTE data;
int side = GLCD_LEFT; // Stores which chip to use on the LCD
if((x > 63)&&(x < 128)) // Check for first or second display area
{
x -= 64;
side = GLCD_MID;
}
else if (x >127)
{
x -=128;
side=GLCD_RIGHT;
}
else
{
side=GLCD_LEFT;
}
output_low(GLCD_DI); // Set for instruction
bit_clear(x,7); // Clear the MSB. Part of an instruction code
bit_set(x,6); // Set bit 6. Also part of an instruction code
glcd_writeByte(side, x); // Set the horizontal address
glcd_writeByte(side, (y/8 & 0xBF) | 0xB8); // Set the vertical page address
output_high(GLCD_DI); // Set for data
glcd_readByte(side); // Need two reads to get data
data = glcd_readByte(side); // at new address
if(color == ON)
bit_set(data, y%8); // Turn the pixel on
else // or
bit_clear(data, y%8); // turn the pixel off
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(side, x); // Set the horizontal address
output_high(GLCD_DI); // Set for data
glcd_writeByte(side, data); // Write the pixel data
}
#endif
//=============================================================================================
// Purpose: Fill the LCD screen with the passed in color
// Inputs: ON - turn all the pixels on
// OFF - turn all the pixels off
void glcd_fillScreen(int1 color)
#ifdef FAST_GLCD
{
unsigned int8 data;
unsigned int8 *p1, *p2, *p3;
unsigned int16 i;
p1 = displayData.left;
p2 = displayData.right;
p3 = displayData.mid;
data = 0xFF * color;
for(i=0; i<512; ++i)
{
*p1++ = data;
*p2++ = data;
*p3++ = data;
}
}
#else
{
unsigned int8 i, j;
// Loop through the vertical pages
for(i = 0; i < 8; ++i)
{
output_low(GLCD_DI); // Set for instruction
glcd_writeByte(GLCD_LEFT, 0b01000000); // Set horizontal address to 0
glcd_writeByte(GLCD_RIGHT, 0b01000000);
glcd_writeByte(GLCD_MID, 0b01000000);
glcd_writeByte(GLCD_LEFT, i | 0b10111000);// Set page address
glcd_writeByte(GLCD_RIGHT, i | 0b10111000);
glcd_writeByte(GLCD_MID, i | 0b10111000);
output_high(GLCD_DI); // Set for data
// Loop through the horizontal sections
for(j = 0; j < 64; ++j)
{
glcd_writeByte(GLCD_LEFT, 0xFF*color); // Turn pixels on or off
glcd_writeByte(GLCD_RIGHT, 0xFF*color); // Turn pixels on or off
glcd_writeByte(GLCD_MID, 0xFF*color); // Turn pixels on or off
}
}
}
#endif
//==================================================================================
// Purpose: Write a byte of data to the specified chip
// Inputs: 1) chipSelect - which chip to write the data to
// 2) data - the byte of data to write
void glcd_writeByte(int1 side, BYTE data)
{
set_tris_d(0x00);
output_low(GLCD_RW); // Set for writing
if(side==0) // Choose which side to write to
output_high(GLCD_CS1);
else if(side==1)
output_high(GLCD_CS2);
else
output_high(GLCD_CS3);
delay_us(1);
output_d(data); // Put the data on the port
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
}
//===============================================================================
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
BYTE glcd_readByte(int1 side)
{
BYTE data; // Stores the data read from the LCD
set_tris_d(0xFF); // Set port d to input
output_high(GLCD_RW); // Set for reading
if(side==0) // Choose which side to write to
output_high(GLCD_CS1);
else if(side==1)
output_high(GLCD_CS2);
else
output_high(GLCD_CS3);
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
data = input_d(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
output_low(GLCD_CS3);
return data; // Return the read data
}
#endif |
|
|
|
albe01
Joined: 02 Jul 2010 Posts: 30 Location: italy
|
|
Posted: Wed Apr 13, 2011 5:28 pm |
|
|
hi! but if the glcd have only cs1 and cs2? in this driver there is a problem... the my lcd have only cs1 and cs2, cs3 is emulated if cs1is=0 and cs2=1
see data on http://www.ciahk.net/upload/docs/HY-19264B.pdf
how to solve this problem? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 14, 2011 5:30 pm |
|
|
Your LCD data sheet refers to CSA and CSB, instead of CS1, 2, 3.
Instead of individual chip select lines for each LCD section, your LCD
encodes the chip selection in two lines, as follows:
Code: |
CSA CSB LCD section
0 0 Left
0 1 Middle
1 0 Right
|
To change the posted driver code to work with your LCD, you need to edit
every place where he sets CS1, 2, 3, and change it to use CSA and CSB
according to the table above. Also, in places where he deselects all
chip select lines, you need to set CSA and CSB both to be high.
Here are the changes you need to do:
In the pin list, you need to comment out the CS1, 2, 3 lines, and add
lines for CSA and CSB as shown below:
Code: |
/*
#ifndef GLCD_CS1
#define GLCD_CS1 PIN_B0 // Chip Selection 1
#endif
#ifndef GLCD_CS2
#define GLCD_CS2 PIN_B1 // Chip Selection 2
#endif
#ifndef GLCD_CS3
#define GLCD_CS3 PIN_B6 // Chip Selection 2
#endif
*/
#ifndef GLCD_CSA
#define GLCD_CSA PIN_B0
#endif
#ifndef GLCD_CSB
#define GLCD_CSB PIN_B1
#endif
|
Also, note that in his driver, the data port for the LCD is hard-coded to
use Port D on the PIC. You must connect pins DB0-7 on the LCD to
Port D, bits 0 to 7.
Edit the first part of the glcd init routine and comment out the existing lines
for CS1, 2, 3. Then add two new lines for CSA and CSB:
Code: |
void glcd_init(int1 mode)
{
// Initialize some pins
output_high(GLCD_RST);
output_low(GLCD_E);
// output_low(GLCD_CS1);
// output_low(GLCD_CS2);
// output_low(GLCD_CS3);
output_high(GLCD_CSA);
output_high(GLCD_CSB);
|
Then delete the existing write byte routine and substitute this one:
Code: |
void glcd_writeByte(int8 side, BYTE data)
{
set_tris_d(0x00);
output_low(GLCD_RW); // Set for writing
switch(side)
{
case GLCD_LEFT:
output_low(GLCD_CSA);
output_low(GLCD_CSB);
break;
case GLCD_MID:
output_low(GLCD_CSA);
output_high(GLCD_CSB);
break;
case GLCD_RIGHT:
output_high(GLCD_CSA);
output_low(GLCD_CSB);
break;
default: // Deselected
output_high(GLCD_CSA);
output_high(GLCD_CSB);
}
delay_us(1);
output_d(data); // Put the data on the port
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
output_low(GLCD_E);
output_high(GLCD_CSA); // Reset the chip select lines
output_high(GLCD_CSB);
}
|
Then delete the existing Read byte routine and substitute this one:
Code: |
BYTE glcd_readByte(int8 side)
{
BYTE data; // Stores the data read from the LCD
set_tris_d(0xFF); // Set port d to input
output_high(GLCD_RW); // Set for reading
switch(side)
{
case GLCD_LEFT:
output_low(GLCD_CSA);
output_low(GLCD_CSB);
break;
case GLCD_MID:
output_low(GLCD_CSA);
output_high(GLCD_CSB);
break;
case GLCD_RIGHT:
output_high(GLCD_CSA);
output_low(GLCD_CSB);
break;
default: // Deselected
output_high(GLCD_CSA);
output_high(GLCD_CSB);
}
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
data = input_d(); // Get the data from the display's output register
output_low(GLCD_E);
output_high(GLCD_CSA); // Reset the chip select lines
output_high(GLCD_CSB);
return data; // Return the read data
} |
|
|
|
albe01
Joined: 02 Jul 2010 Posts: 30 Location: italy
|
|
Posted: Thu Apr 21, 2011 12:52 pm |
|
|
Hi! i have modified it, and in text mode is ok, but in graphix there is a problem, i use glcd_line(0,8,127,8, ON); if i use a value more than of 127 the line is shorter how can I fix it?
if i use glcd_line(0,8,192,8, ON); the line is very short
best regards |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 22, 2011 2:58 pm |
|
|
What file has the glcd_line() source code in it ? What's the filename ? |
|
|
sshahryiar
Joined: 05 May 2010 Posts: 94 Location: Dhaka, Bangladesh
|
Need an example program with the 192x64 GLCD driver |
Posted: Fri Aug 10, 2012 11:09 am |
|
|
Could somebody share a working example with the 192x64 GLCD driver? _________________ https://www.facebook.com/MicroArena
SShahryiar |
|
|
sshahryiar
Joined: 05 May 2010 Posts: 94 Location: Dhaka, Bangladesh
|
192x64 GLCD weird problems |
Posted: Fri Aug 10, 2012 10:28 pm |
|
|
Quote: |
void glcd_writeByte(int1 side, BYTE data)
{
set_tris_d(0x00);
output_low(GLCD_RW); // Set for writing
if(side==0) // Choose which side to write to
output_high(GLCD_CS1);
else if(side==1)
output_high(GLCD_CS2);
else
output_high(GLCD_CS3);
delay_us(1);
output_d(data); // Put the data on the port
delay_us(1);
output_high(GLCD_E); // Pulse the enable pin
delay_us(1);
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
output_low(GLCD_CS3);
}
//===============================================================================
// Purpose: Reads a byte of data from the specified chip
// Ouputs: A byte of data read from the chip
BYTE glcd_readByte(int1 side)
{
BYTE data; // Stores the data read from the LCD
set_tris_d(0xFF); // Set port d to input
output_high(GLCD_RW); // Set for reading
if(side==0) // Choose which side to write to
output_high(GLCD_CS1);
else if(side==1)
output_high(GLCD_CS2);
else
output_high(GLCD_CS3);
delay_us(1);
o[code]utput_high(GLCD_E); // Pulse the enable pin
delay_us(1);
data = input_d(); // Get the data from the display's output register
output_low(GLCD_E);
output_low(GLCD_CS1); // Reset the chip select lines
output_low(GLCD_CS2);
output_low(GLCD_CS3);
return data; // Return the read data
}
#endif |
I guess the bold lines are not correct in the driver file supplied here. _________________ https://www.facebook.com/MicroArena
SShahryiar |
|
|
sshahryiar
Joined: 05 May 2010 Posts: 94 Location: Dhaka, Bangladesh
|
192x64 GLCD issues |
Posted: Fri Aug 10, 2012 10:33 pm |
|
|
PCM Programmer, I need you help. I have mentioned the above errors I saw in the driver file supplied in this thread. I fixed this issues but still I'm unable to display anything in my 192x64 GLCD correctly. Can you help me in this regard? Thanks in advance.... _________________ https://www.facebook.com/MicroArena
SShahryiar |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 10, 2012 10:54 pm |
|
|
There are no errors that I see. There is nothing wrong with the bold lines.
Post the manufacturer and part number of you glcd. Also post a link
to the website for it. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|