64128cog lcd

seagull

New member
64128cog lcd,, check my code please

Hello everyone;
I am trying to run 64128COD LCD using PIC18F2455. The hardware is just what the datasheet says, except I am using ceramic capacitors while the datasheet has electrolytic ones,, I don’t think that would make any different as far as values are the same.
I have read the datasheet for the LCD driver and made the software carefully, but, didn’t work!! I tried to modify the code based on some suggestions that I read over the net and it didn’t work.
Below is my C code, and there is a part of the schematic.. Any advice would be appreciated.

Code:
//LCD ports
#define SID		LATBbits.LATB4
#define SCLK		LATBbits.LATB3
#define RS		LATBbits.LATB2
#define RST		LATBbits.LATB1
#define CS1B		LATBbits.LATB0


	void main(void)
	{

	//	LATB = 0x00;
      	TRISB = 0b00000000; //all outputs 


		// Initialise LCD:
		
		RST = 0; //Reset is Low
		Delay1KTCYx(10);
		RST = 1; //Reset is High

		CS1B = 0; // enable chip
		Delay1KTCYx(3);
		
		RS = 0; // control command
		parallelToSerial(resetLCD);

		LCDinit();
		

		while(1){
			LCDwriteData();
		}
	
	}

void LCDinit(void)
{
	RS = 0; // control command
	parallelToSerial(0XA0);// SEG 132, ADC 0
	parallelToSerial(0XC0); // com direction com_1 64
	parallelToSerial(0XA2);// select LCD biase
	parallelToSerial(0X2F);// voltage converter,regulator, follower are all on
	Delay1KTCYx(10); // delay >1ms
	parallelToSerial(0X26);// regulator resistor
	parallelToSerial(0X81);// refernce voltage1 (default)
	parallelToSerial(0X25);// refernce voltage2 (control contrast)
	Delay1KTCYx(250); // delay > Stabilizing the LCD

}

void LCDwriteData(void)
{
	RS = 0; // control command
	parallelToSerial(InitDisLine);
	parallelToSerial(InitPagAdd);
	parallelToSerial(InitColAddH);
	parallelToSerial(InitColAddL);

	RS = 1; // Data command
	parallelToSerial(0XFF);// any data
	RS = 0; // control command

	parallelToSerial(0XAF);// Turn LCD On

}

void parallelToSerial(unsigned char data)
{
	
	CS1B = 0; // enable chip

	SID = data&0b00000001;
	SCLK = 0;
	SCLK = 1;
	
	SID = data&0b00000010;
	SCLK = 0;
	SCLK = 1;

	SID = data&0b00000100;
	SCLK = 0;
	SCLK = 1;

	SID = data&0b00001000;
	SCLK = 0;
	SCLK = 1;

	SID = data&0b00010000;
	SCLK = 0;
	SCLK = 1;

	SID = data&0b00100000;
	SCLK = 0;
	SCLK = 1;

	SID = data&0b01000000;		
	SCLK = 0;
	SCLK = 1;

	SID = data&0b10000000;	
	SCLK = 0;
	SCLK = 1;

	Delay10TCYx(50);
	CS1B = 1; // disable chip
		
}
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
Last edited:

seagull

New member
Thanks Cosmicvoid.
I spent the day today at uni having the the clock and data lines of the LCD on the scope and I found a fundamental mistake in the parallelToSerial() function.
I have managed to sort it out and at least now I can get the entire LCD on..next step is to start drawing and writing numbers and letter.. If you have any library that contains this I'll appreciate posting it.
For those who are reading this in the future, here is the correct function:
Code:
void parallelToSerial(unsigned char data)
{
	unsigned char i;
	unsigned char out;
	unsigned char temp;


	CS1B = 0; // enable chip

	for (i=0; i<8; i++ ){
		out = data<<i;
		temp = out&0b10000000;
		SID = temp >>7;
		SCLK = 0;
		SCLK = 1;
	}
}
Here is the datasheet of the driver KS0713

:)
 
Top