GLCD two different control ports

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
User avatar
Jordy101091
Posts: 519
Joined: Sat Jan 08, 2011 4:02 pm
Location: The Netherlands
Has thanked: 25 times
Been thanked: 188 times
Contact:

GLCD two different control ports

Post by Jordy101091 »

Hi all,

I have made a prototype PCB where I have connected a GLCD (KS0108) to this microcontroller PIC18F452.
The data lines of the Glcd are connected to PORT.D 0 to 7.
The control lines:

CS2 & D/I are connected to PORT.C 3 & 0
CS1 & Enable & R/W are connected to PORT.E 0 to 2

I have found on the forum that you could make another define in the C code, I have done that, and named it: MX_CONTROL_PORT2, MX_CONTROL_TRIS2

In the "GetDefines" I have altered all code where CS1, Enable, R/W from:

Code: Select all

void MX_Write_Command(char cmd, char chip)
{
	if(chip == MX_CHIP1)						//Select Chip 1
	{
		clear_bit(MX_CONTROL_PORT, MX_CS2);
		set_bit(MX_CONTROL_PORT, MX_CS1);
	}
	else if(chip == MX_CHIP2)					//Select Chip 2
	{
		clear_bit(MX_CONTROL_PORT, MX_CS1);
		set_bit(MX_CONTROL_PORT, MX_CS2);
To

Code: Select all

void MX_Write_Command(char cmd, char chip)
{
	if(chip == MX_CHIP1)						//Select Chip 1
	{
		clear_bit(MX_CONTROL_PORT, MX_CS2);
		set_bit(MX_CONTROL_PORT2, MX_CS1);
	}
	else if(chip == MX_CHIP2)					//Select Chip 2
	{
		clear_bit(MX_CONTROL_PORT2, MX_CS1);
		set_bit(MX_CONTROL_PORT, MX_CS2);
The same I have done in this file "LCD_Init" To:

Code: Select all

clear_bit(MX_CONTROL_TRIS2, MX_ENABLE);				//Convert control pins to output
	clear_bit(MX_CONTROL_TRIS, MX_DAT_INST);
	clear_bit(MX_CONTROL_TRIS2, MX_CS1);
	clear_bit(MX_CONTROL_TRIS, MX_CS2);
	clear_bit(MX_CONTROL_TRIS2, MX_READ_WRITE);

	set_bit(MX_CONTROL_PORT2, MX_ENABLE);
	clear_bit(MX_CONTROL_PORT2, MX_READ_WRITE);			//Write Command
	clear_bit(MX_CONTROL_PORT, MX_DAT_INST);			//Instruction code
	set_bit(MX_CONTROL_PORT2, MX_CS1);					//Select Chip 1
	clear_bit(MX_CONTROL_PORT, MX_CS2);

	MX_Write_Command(MX_LCD_ON, MX_CHIP1);				//Switch on LCD controller chips
	MX_Write_Command(MX_LCD_ON, MX_CHIP2);

	MX_Write_Command(MX_LCD_DISP_START, MX_CHIP1);		//Configure the display start address
	MX_Write_Command(MX_LCD_DISP_START, MX_CHIP2);

	LCD_Clear();
	MX_GotoXY(0,0);

The only problem I have now is that When I print Test on the screen as string the its show two times.
Just if CS1 and CS2 are activated together. Thit I miss something can somebody look into this please,

Thanks you.
Regards Jordy

I have added the Getdefines file and LCD_Init File I dont know if i could help?
Attachments
GetDefines(GLCDKS0108).fcc
(21.94 KiB) Downloaded 200 times
LCD_Init(GLCDKS0108).fcc
(21.94 KiB) Downloaded 205 times
the will to learn, should not be stopped by any price

Post Reply