Pages: [1] 2   Go Down
Author Topic: FIXED: SSD1963 controller with 7" TFT (horizontally mirrored image)  (Read 9406 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a strange issue....

  • I'm running a DUE & IDE 1.52
  • 7" 32 pin TFT touch screen display
  • CTE shield
  • Standard UTFT library (latest version)

What happens?

The main issues is that the entire display is horizontally reversed. (OR I have the screen upside down and it is vertically reversed)

(the 2nd issue is that all the demos in the demo loop from start through to the sin wave fail display strange blocks of colour but this is a lesser issue by far.)



It appears to be something to do with the initialisation of the display and this was confirmed by UTFT's writer who I emailed.

I've downloaded the datasheet for the SSD1963 http://www.techtoys.com.hk/Components/SSD1963QL9/SSD1963_1.1.pdf



I'm not yet sure what it is but I'm thinking that it might have something to do with the frame buffer settings re "set_address_mode command 0x36"

This is the relevant section:




In the library this is the relevant section of code:

The standard setting is 0x03 or 0x22 ??

Now looking at the data sheet I should be setting (as far as I can see)

bit 5=0 (horizontal)
bit 6=0
bit 7=1

This is based on being the horizontal opposite of 0x03 BUT it doesn't work and remains the same.  I was convinced that making the changes wasn't working and it was reading from somewhere else but I "//"d the 'screen on' command and the screen stayed off so it is the right file and SHOULD be working.....

I've tried commenting the two lines out completely but it isn't doing anything whatsoever!!!


Code:
   case SSD1963_800_3:

LCD_Write_COM(0xE2); //PLL multiplier, set PLL clock to 120M
   LCD_Write_DATA(0x23);    //N=0x36 for 6.5M, 0x23 for 10M crystal
   LCD_Write_DATA(0x02);
       LCD_Write_DATA(0x04);

LCD_Write_COM(0xE0); // PLL enable
       LCD_Write_DATA(0x01);
delay(10);
LCD_Write_COM(0xE0);
       LCD_Write_DATA(0x03);
delay(10);
LCD_Write_COM(0x01); // software reset
delay(100);
       LCD_Write_COM(0xE6); //PLL setting for PCLK, depends on resolution
           LCD_Write_DATA(0x04);
           LCD_Write_DATA(0x93);
           LCD_Write_DATA(0xE0);


       LCD_Write_COM(0xB0); //LCD SPECIFICATION
             LCD_Write_DATA(0x0000);
           LCD_Write_DATA(0x0000);
           LCD_Write_DATA((799>>8)&0X00FF);  //Set HDP
           LCD_Write_DATA(799&0X00FF);
                    LCD_Write_DATA((479>>8)&0X00FF);  //Set VDP
           LCD_Write_DATA(479&0X00FF);
                    LCD_Write_DATA(0x0000);

LCD_Write_COM(0xB4); //HSYNC
           LCD_Write_DATA((1000>>8)&0X00FF);  //Set HT
           LCD_Write_DATA(1000&0X00FF);
           LCD_Write_DATA((51>>8)&0X00FF);  //Set HPS
           LCD_Write_DATA(51&0X00FF);
           LCD_Write_DATA(8);   //Set HPW
           LCD_Write_DATA((3>>8)&0X00FF);  //Set HPS
           LCD_Write_DATA(3&0X00FF);
           LCD_Write_DATA(0x0000);

       LCD_Write_COM(0xB6); //VSYNC
                    LCD_Write_DATA((530>>8)&0X00FF);   //Set VT
           LCD_Write_DATA(530&0X00FF);
           LCD_Write_DATA((24>>8)&0X00FF);  //Set VPS
           LCD_Write_DATA(24&0X00FF);
           LCD_Write_DATA(3);   //Set VPW
           LCD_Write_DATA((23>>8)&0X00FF);  //Set FPS
           LCD_Write_DATA(23&0X00FF);


LCD_Write_COM(0xBA);
   LCD_Write_DATA(0x0F); //GPIO[3:0] out 1

LCD_Write_COM(0xBB);
   LCD_Write_DATA(0x07);    //GPIO3=input, GPIO[2:0]=output
   LCD_Write_DATA(0x01); //GPIO0 normal

LCD_Write_COM(0x36); //rotation ****set_address_mode command****
   LCD_Write_DATA(0x03);   //tried 0,1,2,3 but none have ANY effect ???

// LCD_Write_COM(0x20); //invert
//    LCD_Write_DATA(0xff);

       LCD_Write_COM(0x3A); //pixel data interface
   LCD_Write_DATA(0x50);

LCD_Write_COM(0xF0); //pixel data interface
   LCD_Write_DATA(0x03);

delay(1);
setXY(0, 0, 799, 479);

LCD_Write_COM(0x26); //pixel data interface
   LCD_Write_DATA(0x08);

LCD_Write_COM(0x29); //display on

LCD_Write_COM(0xBE); //set PWM for B/L
   LCD_Write_DATA(0x06);
   LCD_Write_DATA(0x55);
   LCD_Write_DATA(0x01);
   LCD_Write_DATA(0xf0);
   LCD_Write_DATA(0x00);
   LCD_Write_DATA(0x00);

LCD_Write_COM(0xd0);
   LCD_Write_DATA(0x0d);

LCD_Write_COM(0x2C);
break;




UPDATE:


Found another section:



This would suggest that you can simply change the direction BUT it says GET not SET.....

Tried adding the lines:

Code:

LCD_Write_COM(0x0B); //horizontal direction
LCD_Write_DATA(64);


BUT nothing I try changing it to works......  still playing though.
« Last Edit: March 05, 2013, 04:29:40 pm by cowasaki » Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11694
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

All these LCD drivers have a bit to control gate-scan direction and a bit to control source-scan direction,
check the datasheet for where these are in the registers.  Don't change the RAM addressing unless you
want to switch landscape <-> portrait - if I remember correctly.

Again if I remember rightly the usual set up is that the RAM addressing bit simply transposes X and Y, which
means a reflection about a diagonal.  There are 8 combinations of these 3 bits giving access to every
rotation and refection sense.  Rotating by 90 degrees involves changing the RAM addressing and one
of the other reflection bits.
Logged

[ I won't respond to messages, use the forum please ]

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The most promising option seemed to be:

0x36 Set_address_mode

BUT

NOTHING happens no matter what I change the value to, in fact if I comment out the line it makes no difference.
Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The UTFT library file UTFT.cpp appears to have a bug in that there are two initialisation sections for the SSD1963_800 the first one is unused.  I've deleted it and it makes no apparent difference.

Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11694
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The most promising option seemed to be:

0x36 Set_address_mode

BUT

NOTHING happens no matter what I change the value to, in fact if I comment out the line it makes no difference.

Address mode only changes the behaviour on sending multiple pixels - IIRC the UTFT library sets up bounding
rectangle before drawing lines / blocks and then sends the right number of pixels - the bounding rect ensures
all the pixels end up in the right place whatever scan-direction is used.

The gate-scan and source-scan bits are what you need to find.
Logged

[ I won't respond to messages, use the forum please ]

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well after doing some more research it appears that left/right direction is controlled by a pin on the LCD i/o bus.

On the actual LCD this pin is pin39 "L<>R" and this pin is connected directly to pin36 of the SSD1963 "GPIO0"

So it would appear that setting the value of GPIO0 to the opposite value that it currently is will reverse it.......

According to the specifications of the SSD1963 there are 4 commands that are to do with the GPIO and these are:

0xB8 = set_gpio_conf = Set the GPIO configuration. If the GPIO is not used for LCD, set the direction. Otherwise, they are toggled with LCD signals.
0xB9 = get_gpio_conf = Get the current GPIO configuration
0xBA = set_gpio_value = Set GPIO value for GPIO configured as output
0xBB = get_gpio_status = Read current GPIO status. If the individual GPIO was configured as input, the value is the status of the corresponding pin. Otherwise, it is the programmed value.

Now to look at the initialisation code.......

   LCD_Write_COM(0xBA);
    LCD_Write_DATA(0x0F);      //GPIO[3:0] out 1

   LCD_Write_COM(0xBB);
    LCD_Write_DATA(0x07);       //GPIO3=input, GPIO[2:0]=output
    LCD_Write_DATA(0x01);      //GPIO0 normal

0xB9 is used to read the port so that is irrelevant BUT 0xBB also appears to be to read the status....

0xB8 is used to set the port up BUT the IO code doesn't actually call this.  I have tried messing with the 0xBA & 0xBB commands above but nothing seems to change.  This is probably because of the lack of a command to actually set the port up.


SO......

It would appear that to fix the issue we need to set the direction of the GPIO port to OUTPUT & set the GPIO0 port to HIGH or LOW (not sure which one yet but if one doesn't work the other should!)


Now looking at the code above

   LCD_Write_COM(0xBB);
    LCD_Write_DATA(0x07);       //GPIO3=input, GPIO[2:0]=output
    LCD_Write_DATA(0x01);      //GPIO0 normal

if would appear that there has been a typo and it should have been

   LCD_Write_COM(0xB8);
    LCD_Write_DATA(0x07);       //GPIO3=input, GPIO[2:0]=output
    LCD_Write_DATA(0x01);      //GPIO0 normal



Well now I've done that it is STILL reversed so I just need to send the opposite value to the GPIO0 port now......
Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset




***** DONE IT *****
[/font][/color]


Replace "0xBB" with "0xB8" to set the GPIO correctly

   LCD_Write_COM(0xB8);
    LCD_Write_DATA(0x07);       //GPIO3=input, GPIO[2:0]=output
    LCD_Write_DATA(0x01);      //GPIO0 normal

Change the output value to "0x0E" which reverses the output

   LCD_Write_COM(0xBA);
    LCD_Write_DATA(0x0E);      //GPIO[3:0] out 1

These changes need to be made in the UTFT.cpp file

Now in the CURRENT version of the library there are TWO sections for the SSD1963_800 so delete the first one which is about line 1822 ish.  Basically just completely remove it as here:

Code:
LCD_Write_COM(0xd0);
LCD_Write_DATA(0x0d);

LCD_Write_COM(0x2C);
break;
#endif

// Delete this section from here

#ifndef DISABLE_S6D1121
case S6D1121_8:
case S6D1121_16:
LCD_Write_COM_DATA(0x11,0x2004);
LCD_Write_COM_DATA(0x13,0xCC00);
LCD_Write_COM_DATA(0x15,0x2600);

Then zoom along to about line 2200 ish and make the changes above ie:

Code:
case SSD1963_800_3:

    LCD_Write_COM(0xE2); //PLL multiplier, set PLL clock to 120M
     LCD_Write_DATA(0x23);    //N=0x36 for 6.5M, 0x23 for 10M crystal
     LCD_Write_DATA(0x02);
     LCD_Write_DATA(0x04);

    LCD_Write_COM(0xE0); // PLL enable
     LCD_Write_DATA(0x01);
    
    delay(10);

    LCD_Write_COM(0xE0);
     LCD_Write_DATA(0x03);
    
    delay(10);

    LCD_Write_COM(0x01); // software reset

    delay(100);

LCD_Write_COM(0xE6); //PLL setting for PCLK, depends on resolution
     LCD_Write_DATA(0x04);
     LCD_Write_DATA(0x93);
     LCD_Write_DATA(0xE0);

LCD_Write_COM(0xB0); //LCD SPECIFICATION
LCD_Write_DATA(0x0000);
LCD_Write_DATA(0x0000);
LCD_Write_DATA((799>>8)&0X00FF);  //Set HDP
LCD_Write_DATA(799&0X00FF);
     LCD_Write_DATA((479>>8)&0X00FF);  //Set VDP
LCD_Write_DATA(479&0X00FF);
     LCD_Write_DATA(0x0000);

LCD_Write_COM(0xB4); //HSYNC
LCD_Write_DATA((1000>>8)&0X00FF);  //Set HT
LCD_Write_DATA(1000&0X00FF);
LCD_Write_DATA((51>>8)&0X00FF);  //Set HPS
LCD_Write_DATA(51&0X00FF);
LCD_Write_DATA(8);   //Set HPW
LCD_Write_DATA((3>>8)&0X00FF);  //Set HPS
LCD_Write_DATA(3&0X00FF);
LCD_Write_DATA(0x0000);

LCD_Write_COM(0xB6); //VSYNC
LCD_Write_DATA((530>>8)&0X00FF);   //Set VT
LCD_Write_DATA(530&0X00FF);
LCD_Write_DATA((24>>8)&0X00FF);  //Set VPS
LCD_Write_DATA(24&0X00FF);
LCD_Write_DATA(3);   //Set VPW
LCD_Write_DATA((23>>8)&0X00FF);  //Set FPS
LCD_Write_DATA(23&0X00FF);

LCD_Write_COM(0xB8);
LCD_Write_DATA(0x07);    //GPIO3=input, GPIO[2:0]=output
LCD_Write_DATA(0x01); //GPIO0 normal

LCD_Write_COM(0xBA);
LCD_Write_DATA(0x0E); //GPIO[3:0] out 1

LCD_Write_COM(0x36); //rotation
LCD_Write_DATA(0x00);

LCD_Write_COM(0x0B); //horizontal direction
LCD_Write_DATA(0xFF);

LCD_Write_COM(0x3A); //pixel data interface
LCD_Write_DATA(0x50);

LCD_Write_COM(0xF0); //pixel data interface
LCD_Write_DATA(0x03);      // 16-bit (565 format)


delay(1);
    setXY(0, 0, 799, 479);

    LCD_Write_COM(0x26); //pixel data interface
LCD_Write_DATA(0x08);

LCD_Write_COM(0x29); //display on

LCD_Write_COM(0xBE); //set PWM for B/L
LCD_Write_DATA(0x01);
LCD_Write_DATA(0x88);
LCD_Write_DATA(0x01);
LCD_Write_DATA(0xf0);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x00);

LCD_Write_COM(0xd0);
LCD_Write_DATA(0x0d);

LCD_Write_COM(0x2C);

break;
« Last Edit: March 05, 2013, 06:55:13 pm by cowasaki » Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been speaking with the creator of the UTFT library Henning Karisen and it would appear that when I download the latest version from his site I am getting an old version, in fact a very old version.  We cannot work out why this is happening but we only realised this when I sent him back a copy of the UTFT.cpp file which was 3 times the size of the current one.  Henning was good enough to send me the latest version and I installed this just changing the TFT type......

Straight away the entire example program works flawlessly and it appeared a little quicker too.


So if it isn't working for you too then maybe it is an internet issue NOT a problem with the library itself.  

If you think that this might apply to you then the latest version should have THIS as the last line of the version file...


   2.01   05 Feb 2013  -  fixed a bug that only shows up on linux-based systems



EDIT:  I had placed the new library files into the library directory but didn't realise that the IDE was still using the modified CTE files I was using.  When I removed all traces of UTFT, Utouch etc and replaced them with the ones from Henning it was no longer working.  I have still not yet managed to get it to work so back to modified CTE files for the moment.
   
« Last Edit: March 08, 2013, 12:03:57 pm by cowasaki » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!! I just was wondering me where can I get the UTFT library Henning Karisen the latest version! Is there somewhere can I get it?

I have a 7" TFT 32 pin Screen the arduino due and the CTE shield and Im not able to run any program from the arduino!

Can somebody give me a hand?
Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you using the DUE?

If you are then download the UTFT_DUE folder from CTE (http://www.ebay.com/itm/7-7-0-inch-TFT-LCD-module-Font-IC-800x480-SSD1963-arduino-DUE-MEGA2560-3-5-4-3-/111008432389?) and modify it as follows:

  • Make sure you are running IDE 1.52
  • Copy UTFT_DUE (the download) into your library folder.
  • Open file UTFT.cpp and modify it as per above ie delete line 1822 (#ifndef DISABLE_SSD1963_800) -1902 (#endif) {this is the first instance of the init routine} then replace what are now lines 2174 (case SSD1963_800_3:) to 2261 (break:) with the lines shown above.
  • Restart Arduino IDE.
  • Load example program CTE_70inch_800x480
  • In the function loop() delete everything from the start of the function up to but not including "int buf[798];"
  • Run it


It SHOULD now work.....


Note:  There is a line "  myGLCD.Swtich_LCD_TB_Bit(1); " which reverses the screen horizontally.  Some of the example include it and some do not include it !!  So, now that the UTFT demo works try the others BUT if any are backwards just add the above line straight after the first clear screen.



Henning's library is VERY tidy and looks really good.  I am STILL trying to get it to work but I appear to have an unsupported 7" screen so at the moment I'm stuck with the CTE version.  If I get Henning's latest one to work I will give step by step instructions as I have above.
« Last Edit: March 08, 2013, 12:32:06 pm by cowasaki » Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In CTE's version of Henning's library you can initialise the library using the command:

//UTFT myGLCD(model);
UTFT myGLCD(CTE70);

Which is basically telling it that you are using a 7" TFT screen on a CTE shield.

With Henning's original library you have to specify the pins used for the control lines so.

//UTFT(model,RS,WR,CS,RST{,SER}); where SER is optional
UTFT(SSD1963_800,25,26,27,28);

But nothing happens.  I got the control line numbers:

25 for RS
26 for WR
27 for CS
28 for RST

from CTE's circuit diagram for their shield comparing it against the DUE/MEGA's digital pin numbers. 
Logged

UK
Offline Offline
Sr. Member
****
Karma: 7
Posts: 436
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tried to replace the init routine in Henning's latest library with the code above by replacing the code inside the file at:

tft_drivers/ssd1963/800/initlcd.h

but again no effect.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes Im using Arduino Due!

I followed all your instructions for my own sample code... I only drew a rectangle, a circle, and a line of text.
In my code, I begin by clearing the screen, followed by this command:
myGLCD.Swtich_LCD_TB_Bit(0);

If I ommited it, then my text was mirrored horizontally.

Thank you for your help, the CTE UTFT libraries now work with my 7" SSD1963 display. Looking forward to trying the 5 " model.
I will be watching your work with the Henning's library too.
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11694
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been speaking with the creator of the UTFT library Henning Karisen and it would appear that when I download the latest version from his site I am getting an old version, in fact a very old version.  We cannot work out why this is happening but we only realised this when I sent him back a copy of the UTFT.cpp file which was 3 times the size of the current one.

Your browser is caching the old one?  flush the caches and try again.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys,

what's the status of this issue ?

I've just made it work - Arduino Due + 7" TFT + UTFT library [ Henning Karlsen ] + same tweaks [ inspired by this topic ]

Logged

Pages: [1] 2   Go Up
Jump to: