ST7565 graphical LCD Serial

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

ST7565 graphical LCD Serial

Post by cruzxia »

I want to use a 128 x 64 gLCD with a ST7565 controller. From the data sheet it can be connected in parallel or serial data formats. I want to connect it with a serial interface to reduce the number of connections.
Can I use the Flowcode V4 gLCD (in the output menu) as it is configured for serial data.
Or
Will I have to modify and create custom code for the ST7565 to use serial data.

Andrew

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ST7565 graphical LCD Serial

Post by Benj »

Hello Andrew,

There is a custom component available from here to drive the ST7565 LCD using Flowcode.

http://www.matrixmultimedia.com/Flowcode_Components.php

I think it uses the parrallel method of writing to the display but you should be able to modify the component code so that it uses the alternative serial format. Let me know how you get on.

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

Re: ST7565 graphical LCD Serial

Post by cruzxia »

Hi Ben

I finally received my serial displays. I decided to bit bang the data, as it is only data out (you can’t read from the display in serial mode).
I can’t seem to get the display to initialise. The SPI data is read from the serial data pin in the rising edge of the serial clock. D7 through D0 (MSB first)
I have been using a Custom C code component in Flowcode 4. Here is the bit bang section, can you see any problems?

To send a command I use:

Code: Select all

gLCD_SendByte(MX_LCD_CMD,0xA4);	// where 0xA4 is the command data


To send data I use:

Code: Select all

 gLCD_SendByte(MX_LCD_PARAM,DATA);     // Where Pram is 1


This is the code to send a byte.

Code: Select all

void gLCD_SendByte (char Command, char Lcdout)
{
/*Macro_gLCD_SendByte_Start*/
    char i;

    clear_bit(MX_CONTROL_PORT, MX_CS1);              //MX_GLCD_CS1 0 start of sequence
    clear_bit(MX_CONTROL_PORT, MX_SCLK);            //Clock 0

    if (Command == MX_LCD_CMD)
    {
        clear_bit(MX_CONTROL_PORT, MX_DAT_INST);       //0 = MX_LCD_CMD
    }
    else
    {
        set_bit(MX_CONTROL_PORT, MX_DAT_INST);         //1 = MX_GLCD_PARAMeter
    }

    set_bit(MX_CONTROL_PORT, MX_SCLK);

    for (i=0;i<8;i++)
    {
        clear_bit(MX_CONTROL_PORT, MX_SCLK);        //Clock 0

        if (Lcdout & 0x80)
            set_bit(MX_CONTROL_PORT, MX_SDATA);     //Output MSB

        else
            clear_bit(MX_CONTROL_PORT, MX_SDATA);

        set_bit(MX_CONTROL_PORT, MX_SCLK);          //Clock 1
        Lcdout = Lcdout << 1;                             //Shift Data to left

    }
    set_bit(MX_CONTROL_PORT, MX_CS1);                //MX_GLCD_CS1 to 1 at end of sequence
I will setup the print string code once I know that the comunication is working.

Andrew

Data sheet info is as follows:
Attachments
SS7565.jpg
SS7565.jpg (142.54 KiB) Viewed 7321 times

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

Re: ST7565 graphical LCD Serial

Post by cruzxia »

Hi Ben
Good news
I found the problem it was a hardware issue, one wire had come off the connector. So The SPI code works I posted previously works.

However!
When it prints a string it is just a row of solid pixels. I used your ST7565 code example for the parallel version, but it needs to read the display in most subroutines. Any ideas how to overcome this problem?

Andrew

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ST7565 graphical LCD Serial

Post by Benj »

Hello Andrew,

Great glad you got it working. When printing a string are you using the ASCII look up table method? Eg there is a set of arrays that contain the data for each ASCII charater. The print routine should scan the ascii data and set a pixel if the appropriate ascii data bit is set? Are other functions such as draw line etc working as expected?

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

Re: ST7565 graphical LCD Serial

Post by cruzxia »

Ben

I decided to test the Parallel interface first, to check that it worked as expected. There are two versions ST7565R chip, (6800 series and 8080 series) typically I have the other version.
The changes for the 8080 version were to do with communication. As follows:

Write a Command AO = L , RD = H , WR = L , Move data to port , CS1 = L , delay , CS1 = H
Write Data AO = H , RD = H , WR = L , Move data to port , CS1 = L , delay , CS1 = H
Read DisplayAO = H , RD = L , WR = H , CS1 = L , delay, Read port , CS1 = H

The problem I have is that it wont display any characters correctly and seems to be double spaced.
I think that it has something to do with Reading the display, or the page function. When I draw a text box it seems to not recognise the vertical line numbers, It jumps up 8 pixels at a time.
Eg doing an outline the top is either not there or about 8 pixels thick. photo below
In the photo, Inside the box, the text is “Hello” (centre) and I drew two lines one across the bottom and one vertically in front of the text.
Note: I disabled the Read display function, and the horizontal line draws correctly, but vertical line and text are not displayed.

I read the data sheet, and it said that when sending display data, the specified column address is incremented with each display data read/write command.

I have attached the custom C code that I have revised the comunication from the 6800 to the 8080 version of the ST7565R, can you please have a quick look if I missed something.

Thanks

Andrew
Attachments
PIC_Custom.c
(21.63 KiB) Downloaded 353 times
IMAG0059.jpg
IMAG0059.jpg (222.44 KiB) Viewed 7293 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ST7565 graphical LCD Serial

Post by Benj »

Hello Andrew,

Looks like your nearly there. I had a quick look at your C file but without hardware to test on and digging into the datasheet its hard to tell if its ok. My guess is that the coordinate system you are using is not quite right and this is causing the display to be corrupted. I know that on these black and white devices you write to 8 pixels in one go rather then a pixel at a time as with the colour displays. Maybe this could be the issue? Let me know how your getting on and ill have a bit of a better look when I get some time.

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

Re: ST7565 graphical LCD Serial

Post by cruzxia »

Hi Ben

I am having trouble finding the problem :cry: ; I have narrowed it down to two possible causes.

1. When reading/writhing to the display the line is automatically incremented in the display.
This shows up as spread out text on the display

2. The page system of the display requires setting the page and column via commands.
So the x y positions are incorrect if you don’t set the page.

The c coding that I have used was the file for the ST7565 display so if it was originally tested with a display it should be correct.

To test the display I created a Print Bytes routine, input the ASCII 5 character values, and it prints on the screen In 8x5. So the screen works. The display automatically moves to the next line after each character value is written.

Code: Select all

void LCD_Print_Bytes(char byt1, char byt2, char byt3, char byt4, char byt5, char x, char y)
{
/*Macro_LCD_Print_Bytes_Start*/

		MX_GotoXY(x, y);
		set_bit(MX_CONTROL_PORT, MX_DAT_AO);			//Configure = data
		set_bit(MX_CONTROL_PORT, MX_READ_WRITE_RD);		//Configure to write data !
		set_bit(MX_CONTROL_PORT, MX_READ_WRITE_WR);			//Write cammand

	MX_DATA_TRIS = 0x00;						//Configure data port as output
	MX_DATA_PORT = byt1;							//Load data to port
	MX_LCD_Enable();
	MX_DATA_PORT = byt2;							//Load data to port
	MX_LCD_Enable();
	MX_DATA_PORT = byt3;							//Load data to port
	MX_LCD_Enable();
	MX_DATA_PORT = byt4;							//Load data to port
	MX_LCD_Enable();
	MX_DATA_PORT = byt5;							//Load data to port
	MX_LCD_Enable();
						 	

	MX_DATA_PORT = 0x00;

//MX_WriteData(byt);

/*Macro_LCD_Print_Bytes_End*/
}
The data sheet is here.
http://www.sitronix.com.tw/sitronix/SAS ... 980914.pdf

See page 26 and 27

Thanks
Andrew

cruzxia
Posts: 88
Joined: Wed Jan 04, 2006 7:34 am
Been thanked: 8 times

Re: ST7565 graphical LCD Serial

Post by cruzxia »

Ben

I just did an X Y position test using 8x5 pixel blocks.
If X and Y are 0,0 it prints in the corner as expected
If X and Y are 0,8 it prints 8 pixels up as expected
If X and Y are 0,7 it prints back in the corner. Not expected. So there seems to be some issue with the pages and vertical coordinates.

Do you have any ideas on the XY problem? If I can fix this then the rest may fall in to place.

Andrew

Post Reply