SSD1963 controller problem

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

SSD1963 controller problem

#1 Post by Cyberzim » 12 Apr 2012 17:53

Hi,
I've just started working with a 5,7" TFT display with the SSD1963 controller. But I have encountered a problem.
I get random output on the screen. I will also note you that I accidently added 5V to the display and not 3.3V.
But that doesn't seem to have broken the controller, since I only get this flickering when I startup the display. I can still send command to the controller and it does the desired command (for example turn on the display).
The flickering still appears even if I remove the microcontroller.

Here is my code for sending a command (Chip select is controlled elsewhere in my program):

Code: Select all

//Sends command to display.
void SSD1963Command(unsigned short cmd) {

     RD = 1;
     DC = 0;

     DATA = cmd;
     WR = 0;
     WR = 1;
}
Here is my code for sending data.

Code: Select all

void SSD1963Data(unsigned short dataout) {

     RD = 1;
     DC = 1;

     DATA = dataout;
     WR = 0;
     WR = 1;
}
Here is my current startup of the display:

Code: Select all

//Initializes display.
void SSD1963Init() {

     //Setup ports.
     DATA = 0x00;
     DC = 0;
     WR = 0;
     RD = 0;
     CS = 0;
     RS = 0;
     
     TDATA = 0x00;
     TDC = 0;
     TWR = 0;
     TRD = 0;
     TCS = 0;
     TRS = 0;
     
     //Init port settings.
     WR = 1;
     RD = 1;
     CS = 0;
     
     //Waits for supply to stabilize.
     delay_ms(10);

     //Performs hardware reset.
     RS = 0;
     delay_ms(100);
     RS = 1;
     delay_ms(100);
     
     //Software reset.
     SSD1963Command(0x01);
     //Exit sleep mode.
     SSD1963Command(0x11);
     //Normal mode.
     SSD1963Command(0x13);
     //Exit idle mode.
     SSD1963Command(0x38);
     //Display on.
     SSD1963Command(0x29);
}
I'm not quite sure how to initialize the display correctly, also I would like to know if my data sending command is valid.
Any suggestions?

Regards,

Simon H.A.

PS: Here is a picture of my lcd running: http://img535.imageshack.us/img535/8841/dsc0395sa.jpg

Edit: The output is flickering (like when you have no signal on an old style television).
Name: Simon H.A.
Age: 17

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: SSD1963 controller problem

#2 Post by janko.kaljevic » 17 Apr 2012 13:15

Hello,

The image of your screen looks like the display was not initialized properly.
We have tested this controller in 8 and 16 bit mode and with default screen resolution.

From this point of view I can not tell where you made mistake.
Please tell me which mode and resolution do you use?

Best regards.

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#3 Post by Cyberzim » 19 Apr 2012 00:37

Here is an updated version of my code. It gives me a different output but it's not functional yet.
I have a doubt on how to set HSP and VSP.

Code: Select all

#define TDATA  TRISB
#define TDC    TRISD.F4
#define TWR    TRISD.F5
#define TCS    TRISD.F6
#define TRST    TRISD.F7

#define DATA   PORTB
#define DC    PORTD.F4
#define WR    PORTD.F5
#define CS    PORTD.F6
#define RST    PORTD.F7

//Sends command to display.
void SSD1963Command(unsigned char cmd) {

     DC = 0;
     DATA = cmd;
     
     WR = 0;
     CS = 0;
     CS = 1;
     WR = 1;
}

//Sends 8-bit data to display.
void SSD1963Data(unsigned char dataout) {

     DC = 1;
     DATA = dataout;

     WR = 0;
     CS = 0;
     CS = 1;
     WR = 1;
}

//Sends 24-bit color data to dispaly.
void SSD1963SendData(unsigned long color) {
     //Red
     SSD1963Data((color) >> 16);
     //Green
     SSD1963Data((color) >> 8);
     //Blue
     SSD1963Data(color);
}

//Initializes display.
void SSD1963Init() {

     //Setup ports.
     DATA = 0x00;
     DC = 1;
     WR = 1;
     CS = 1;

     TDATA = 0x00;
     TDC = 0;
     TWR = 0;
     TCS = 0;
     TRST = 0;
     
     //Init port settings.
     WR = 1;
     CS = 1;

     //Performs hardware reset.
     RST = 0;
     delay_us(500);
     RST = 1;
     delay_us(500);
     
     //Software reset.
     SSD1963Command(0x01);
     delay_ms(5);
     SSD1963Command(0x01);
     delay_ms(5);
     SSD1963Command(0x01);
     delay_ms(5);
     
     //Start PLL.
     SSD1963Command(0xE0);
     SSD1963Data(0x01);
     
     //Lock PLL.
     SSD1963Command(0xE0);
     SSD1963Data(0x03);
     
     //Set LCD mode.
     SSD1963Command(0xB0);
     //Set TFT mode + hsync/vsync. 24 bit color.
     SSD1963Data(0x2C);
     SSD1963Data(0x80);
     //Horizontal size.
     SSD1963Data(0x02);
     SSD1963Data(0x7F);
     //Vertical size.
     SSD1963Data(0x01);
     SSD1963Data(0xDF);
     //Set even/odd line RGB.
     SSD1963Data(0x00);
     
     //Set pixel data format (8-bit).
     SSD1963Command(0xF0);
     SSD1963Data(0x00);

     //Set PLL frequency.
     SSD1963Command(0xE2);
     SSD1963Data(0x32);
     SSD1963Data(0x01);
     SSD1963Data(0x04);
     
     //Set HBP.
     SSD1963Command(0xB4);
     SSD1963Data(0x01);
     SSD1963Data(0xB8);
     SSD1963Data(0x00);
     SSD1963Data(0x44);
     SSD1963Data(0x0F);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     
     //Set VBP.
     SSD1963Command(0xB6);
     SSD1963Data(0x01);
     SSD1963Data(0x08);
     SSD1963Data(0x00);
     SSD1963Data(0x12);
     SSD1963Data(0x07);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     
     //Sets column address to 0.
     SSD1963Command(0x2a);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     //Set end column address to 639.
     SSD1963Data(0x02);
     SSD1963Data(0x7F);
     //Sets page address to 0.
     SSD1963Command(0x2b);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     //Set end page address to 479.
     SSD1963Data(0x01);
     SSD1963Data(0xDF);
     
     //Set normal mode.
     SSD1963Command(0x13);
     
     //Display on.
     SSD1963Command(0x29);
     
     

}

void main() {

     ADCON1 = 0x0F;
     CMCON = 0x07;
     INTCON = 0x00;
     SSD1963Init();

}
My controller is set for 8-bit and 8080 mode.

Here is a video of the current output from lcd: http://tinypic.com/r/2ufunip/5
Name: Simon H.A.
Age: 17

Malcolm_M
Posts: 184
Joined: 12 May 2007 13:01
Location: Bristol, UK

Re: SSD1963 controller problem

#4 Post by Malcolm_M » 19 Apr 2012 07:34

Simon,

Have a look at this thread:

SSD1963 Example http://www.mikroe.com/app/webroot/forum ... 01&t=45480

Ideally you have an Application Note from the manufacturer of the display you are using, which details the initialisation for their display.

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#5 Post by Cyberzim » 19 Apr 2012 10:58

I'll take a look on it later today. The problem is, that my display, which is from Newhaven http://www.newhavendisplay.com/index.ph ... ts_id=4304 doesn't supply with that much info. Nothing about how to initialize the display, and the appnotes doesn't either have the correct display model.

Regards,

Simon H.A.
Name: Simon H.A.
Age: 17

Malcolm_M
Posts: 184
Joined: 12 May 2007 13:01
Location: Bristol, UK

Re: SSD1963 controller problem

#6 Post by Malcolm_M » 19 Apr 2012 12:53

I presume you have looked at this app. note on Newhaven website ? The only difference is I <> L at the end of the part number.

http://www.newhavendisplay.com/app_note ... F-CTXI.txt

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#7 Post by Cyberzim » 19 Apr 2012 12:59

Yes, that was my first app note I tried to use (not the first code I posted). Didn't work at all.
My current initialization code is the closest I've got to make it functioning.

Regards,

Simon H.A.
Name: Simon H.A.
Age: 17

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#8 Post by Cyberzim » 20 Apr 2012 15:08

After trying some different values I've finally made the display appear solid black after initialization. But I can't write any data to the display.
Here is a code that should initialize the display and paint it fully red afterward:

Code: Select all

#define TDATA  TRISB
#define TDC    TRISD.F4
#define TWR    TRISD.F5
#define TCS    TRISD.F6
#define TRST    TRISD.F7

#define DATA   PORTB
#define DC    PORTD.F4
#define WR    PORTD.F5
#define CS    PORTD.F6
#define RST    PORTD.F7

//Sends command to display.
void SSD1963Command(unsigned char cmd) {

     DC = 0;
     DATA = cmd;
     
     WR = 0;
     CS = 0;
     CS = 1;
     WR = 1;
}

//Sends 8-bit data to display.
void SSD1963Data(unsigned char dataout) {

     DC = 1;
     DATA = dataout;

     WR = 0;
     CS = 0;
     CS = 1;
     WR = 1;
}

//Sends 24-bit color data to dispaly.
void SSD1963SendData(unsigned long color) {
     //Red
     SSD1963Data((color) >> 16);
     //Green
     SSD1963Data((color) >> 8);
     //Blue
     SSD1963Data(color);
}

//Initializes display.
void SSD1963Init() {

     //Setup ports.
     DATA = 0x00;
     DC = 1;
     WR = 1;
     CS = 1;

     TDATA = 0x00;
     TDC = 0;
     TWR = 0;
     TCS = 0;
     TRST = 0;
     
     //Init port settings.
     WR = 1;
     CS = 1;

     //Performs hardware reset.
     RST = 0;
     delay_us(500);
     RST = 1;
     delay_us(500);
     
     //Software reset.
     SSD1963Command(0x01);
     delay_ms(5);
     SSD1963Command(0x01);
     delay_ms(5);
     SSD1963Command(0x01);
     delay_ms(5);
     
     //Start PLL.
     SSD1963Command(0xE0);
     SSD1963Data(0x01);
     delay_us(100);
     //Lock PLL.
     SSD1963Command(0xE0);
     SSD1963Data(0x03);
     
     //Set PLL frequency (10 MHZ onboard crystal) = (10Mhz*60)/2 = 300 MHz.
     SSD1963Command(0xE2);
     SSD1963Data(0x3B);
     SSD1963Data(0x01);
     SSD1963Data(0x04);

     //Sets pixel clock to approx 56.25 MHz.
     SSD1963Command(0xE6);
     SSD1963Data(0x03);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     
     //Set LCD mode.
     SSD1963Command(0xB0);
     //Set TFT mode + hsync/vsync. 18 bit color.
     SSD1963Data(0x0C);
     SSD1963Data(0x80);
     //Horizontal size.
     SSD1963Data(0x02);
     SSD1963Data(0x7F);
     //Vertical size.
     SSD1963Data(0x01);
     SSD1963Data(0xDF);
     //Set even/odd line RGB.
     SSD1963Data(0x00);
     
     //Set pixel data format (8-bit).
     SSD1963Command(0xF0);
     SSD1963Data(0x00);
     
     //Sets RGB format 6 6 6.
     SSD1963Command(0x3A);
     SSD1963Data(0x60);

     //Set HBP.
     SSD1963Command(0xB4);
     //Horizontal period in lines.
     SSD1963Data(0x02);
     SSD1963Data(0x81);
     //non-display period in lines.
     SSD1963Data(0x02);
     SSD1963Data(0x80);
     //Horizontal sync pulse width.
     SSD1963Data(0x07);
     //Horizontal start location.
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     //Horizontal sub pixel start location.
     SSD1963Data(0x00);
     
     //Set VBP.
     SSD1963Command(0xB6);
     //Vertical period in lines.
     SSD1963Data(0x01);
     SSD1963Data(0xE1);
     //non-display period in lines.
     SSD1963Data(0x01);
     SSD1963Data(0xE0);
     //Vertical sync pulse width.
     SSD1963Data(0x07);
     //Vertical start location.
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     
     //Sets column address to 0.
     SSD1963Command(0x2a);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     //Set end column address to 639.
     SSD1963Data(0x02);
     SSD1963Data(0x7F);
     //Sets page address to 0.
     SSD1963Command(0x2b);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     //Set end page address to 479.
     SSD1963Data(0x01);
     SSD1963Data(0xDF);
     
     //Set normal mode.
     SSD1963Command(0x13);
     
     //Display on.
     SSD1963Command(0x29);
     delay_ms(5);
}

void main() {
     int i, j;
     
     ADCON1 = 0x0F;
     CMCON = 0x07;
     INTCON = 0x00;
     SSD1963Init();

     SSD1963Command(0x2a);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     SSD1963Data(0x02);
     SSD1963Data(0x7F);

     SSD1963Command(0x2a);
     SSD1963Data(0x00);
     SSD1963Data(0x00);
     SSD1963Data(0x01);
     SSD1963Data(0xDF);

     SSD1963Command(0x3C);

     for(i = 0; i < 640; i++) {
           for(j = 0; j < 480; j++) {
                 SSD1963Data(0x3F);
                 SSD1963Data(0x00);
                 SSD1963Data(0x00);
           }
     }

}
Regards,

Simon H.A.
Name: Simon H.A.
Age: 17

Malcolm_M
Posts: 184
Joined: 12 May 2007 13:01
Location: Bristol, UK

Re: SSD1963 controller problem

#9 Post by Malcolm_M » 20 Apr 2012 22:43

Refering to the "Parallel 8080-series Interface Timing Diagram (Write Cycle)" in the SSD1963 data sheet:

Code: Select all

WR = 0;
CS = 0;
CS = 1;
WR = 1;

Should be:

CS = 0;
WR = 0;
WR = 1;
CS = 1;
If the TFT is initialised correctly, the whole screen will be filled with multi-coloured dots due to the random contents of the display RAM at power up.

1) Start with a slow clock ~8MHz and PLL OFF (if uP has one) and once the display is working increase the clock.

I have just increased the uP clock from 32 to 64MHz and had to add some delays to get the TFT to initialise correctly again.

2) Assuming your uP is >= PIC18 use LAT and not PORT to avoid 'read-modify-write' problems.

3) From the data sheet: "fMCLK System Clock Frequency* 1 - 110 MHz" so your setting of 300MHz is out of range.

If you don't have the SSD1963 data sheet, send me a PM and I will email it to you (too big to attach to this post).
Attachments
SSD1963 Write.JPG
SSD1963 Write.JPG (28.69 KiB) Viewed 7624 times

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#10 Post by Cyberzim » 21 Apr 2012 13:15

Thank you very much!
The delay was the only thing that kept me from initializing the display properly. After adding delay it is now fully working.

Great regards,

Simon H.A.

Edit: I have a little problem. A tiny is black all the time. It's not a pixel error since it doesn't appear from the beginning: http://desmond.imageshack.us/Himg31/sca ... es=landing
Name: Simon H.A.
Age: 17

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#11 Post by Cyberzim » 23 Apr 2012 18:19

No suggestion at all? Here is my test code:

Code: Select all

/*This library is written for the SSD1963 LCD display controller.
**Author: Simon H.A.
**Device: PIC18F4455
**Speed: 48MHz (4 MHz crystal w. PLL)
*/

#define TDATA  TRISB
#define TDC    TRISD.F4
#define TWR    TRISD.F5
#define TCS    TRISD.F6
#define TRST    TRISD.F7

#define DATA   PORTB
#define DC    PORTD.F4
#define WR    PORTD.F5
#define CS    PORTD.F6
#define RST    PORTD.F7

//Sends command to display with delay.
void SSD1963InitCommand(unsigned char cmd) {

     DC = 0;
     DATA = cmd;

     CS = 0;
     WR = 0;
     delay_cyc(10);
     WR = 1;
     CS = 1;
     delay_cyc(10);
}

//Sends 8-bit data to display with delay.
void SSD1963InitData(unsigned char dataout) {

     DC = 1;
     DATA = dataout;

     CS = 0;
     WR = 0;
     delay_cyc(10);
     WR = 1;
     CS = 1;
     delay_cyc(10);
}

//Sends command to display.
void SSD1963Command(unsigned char cmd) {

     DC = 0;
     DATA = cmd;
     
     CS = 0;
     WR = 0;
     WR = 1;
     CS = 1;
}

//Sends 8-bit data to display.
void SSD1963Data(unsigned char dataout) {

     DC = 1;
     DATA = dataout;
     
     CS = 0;
     WR = 0;
     WR = 1;
     CS = 1;
}

//Sends 24-bit color data to dispaly.
void SSD1963SendData(unsigned long color) {
     //Red
     SSD1963Data((color) >> 16);
     //Green
     SSD1963Data((color) >> 8);
     //Blue
     SSD1963Data(color);
}

//Sets an area to paint.
void LCDSetArea(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) {

     SSD1963Command(0x2A);
     SSD1963Data(x1 >> 8);
     SSD1963Data(x1);
     SSD1963Data(x2 >> 8);
     SSD1963Data(x2);

     SSD1963Command(0x2B);
     SSD1963Data(y1 >> 8);
     SSD1963Data(y1);
     SSD1963Data(y2 >> 8);
     SSD1963Data(y2);
}

//Initializes display.
void SSD1963Init() {

     //Setup ports.
     DATA = 0x00;
     DC = 1;
     WR = 1;
     CS = 1;

     TDATA = 0x00;
     TDC = 0;
     TWR = 0;
     TCS = 0;
     TRST = 0;
     
     //Init port settings.
     WR = 1;
     CS = 1;

     //Performs hardware reset.
     RST = 0;
     delay_ms(5);
     RST = 1;
     delay_ms(100);
     
     //Software reset.
     SSD1963InitCommand(0x01);
     SSD1963InitCommand(0x01);
     SSD1963InitCommand(0x01);
     delay_ms(10);
     
     //Start PLL.
     SSD1963InitCommand(0xE0);
     SSD1963InitData(0x01);
     delay_us(500);
     //Lock PLL.
     SSD1963InitCommand(0xE0);
     SSD1963InitData(0x03);
     
     //Set LCD mode.
     SSD1963InitCommand(0xB0);
     //Set TFT mode + hsync/vsync. 18 bit color.
     SSD1963InitData(0x0C);
     SSD1963InitData(0x80);
     //Horizontal size.
     SSD1963InitData(0x02);
     SSD1963InitData(0x7F);
     //Vertical size.
     SSD1963InitData(0x01);
     SSD1963InitData(0xDF);
     //Set even/odd line RGB.
     SSD1963InitData(0x00);
     
     //Sets address mode (left to right. top to bottom).
     SSD1963InitCommand(0x36);
     SSD1963InitData(0x40);
     
     //Set pixel data format (8-bit).
     SSD1963InitCommand(0xF0);
     SSD1963InitData(0x00);

     //Sets RGB format 6 6 6.
     SSD1963InitCommand(0x3A);
     SSD1963InitData(0x60);

     //Set PLL frequency (10 MHZ onboard crystal) = (10Mhz*60)/3 = 200 MHz.
     SSD1963InitCommand(0xE2);
     SSD1963InitData(0x3B);
     SSD1963InitData(0x02);
     SSD1963InitData(0x04);

     //Sets pixel clock to approx 4.94 MHz.
     SSD1963InitCommand(0x02);
     SSD1963InitData(0x06);
     SSD1963InitData(0xFF);
     SSD1963InitData(0xFF);

     //Set HBP.
     SSD1963InitCommand(0xB4);
     //Horizontal period in lines.
     SSD1963InitData(0x02);
     SSD1963InitData(0xF8);
     //non-display period in lines.
     SSD1963InitData(0x00);
     SSD1963InitData(0x44);
     //Horizontal sync pulse width.
     SSD1963InitData(0x0F);
     //Horizontal start location.
     SSD1963InitData(0x00);
     SSD1963InitData(0x00);
     //Horizontal sub pixel start location.
     SSD1963InitData(0x00);
     
     //Set VBP.
     SSD1963InitCommand(0xB6);
     //Vertical period in lines.
     SSD1963InitData(0x01);
     SSD1963InitData(0xF8);
     //non-display period in lines.
     SSD1963InitData(0x00);
     SSD1963InitData(0x13);
     //Vertical sync pulse width.
     SSD1963InitData(0x07);
     //Vertical start location.
     SSD1963InitData(0x00);
     SSD1963InitData(0x00);
     
     //Sets column address to 0.
     SSD1963InitCommand(0x2B);
     SSD1963InitData(0x00);
     SSD1963InitData(0x00);
     //Set end column address to 639.
     SSD1963InitData(0x02);
     SSD1963InitData(0x7F);
     //Sets page address to 0.
     SSD1963InitCommand(0x2B);
     SSD1963InitData(0x00);
     SSD1963InitData(0x00);
     //Set end page address to 479.
     SSD1963InitData(0x01);
     SSD1963InitData(0xDF);

     //Display on.
     SSD1963InitCommand(0x29);
     delay_ms(5);
}

void main() {
     int i, j;

     ADCON1 = 0x0F;
     CMCON = 0x07;
     INTCON = 0x00;
     SSD1963Init();
     
     //Fill screen test.
     do {

     LCDSetArea(0, 0, 639, 479);
     SSD1963Command(0x2C);

     for(i = 0; i < 480; i++) {
           for(j = 0; j < 640; j++) {
                 SSD1963SendData(0xFF0000);
           }
     }

     LCDSetArea(0, 0, 639, 479);
     SSD1963Command(0x2C);

     for(i = 0; i < 480; i++) {
           for(j = 0; j < 640; j++) {
                 SSD1963SendData(0x00FF00);
           }
     }

     LCDSetArea(0, 0, 639, 479);
     SSD1963Command(0x2C);

     for(i = 0; i < 480; i++) {
           for(j = 0; j < 640; j++) {
                 SSD1963SendData(0x0000FF);
           }
     }
     
     }while(1);
}
Regards,

Simon H.A.
Name: Simon H.A.
Age: 17

Malcolm_M
Posts: 184
Joined: 12 May 2007 13:01
Location: Bristol, UK

Re: SSD1963 controller problem

#12 Post by Malcolm_M » 23 Apr 2012 20:50

Hi Simon,

Pleased to see you have your display working :D
Edit: I have a little problem. A tiny is black all the time. It's not a pixel error since it doesn't appear from the beginning
I am not sure what you mean by: "It's not a pixel error since it doesn't appear from the beginning" ?

From your image, the top/ right pixel stays black is this correct ?

I code in Pascal so am not really that experienced in C but your code looks fine.

Cyberzim
Posts: 104
Joined: 12 Jun 2008 00:09
Location: Denmark

Re: SSD1963 controller problem

#13 Post by Cyberzim » 23 Apr 2012 20:59

Okay, after a double check the corner is still black even with the random pixel that appears after initialization. It's pretty weird why it does so :S
Name: Simon H.A.
Age: 17

Post Reply

Return to “mikroC PRO for PIC General”