getting a ssd1963 chipset tft on elechouse v2.1 shield to work with adafruit_GFX

hi everyone.

I want to build the following project that can be located on the following link

https://create.arduino.cc/projecthub/dEskoG/rduinoscope-4d399c?f=1

my problem is that the original project uses a HX8532 tft based screen. These are no longer available. the one i was supplied with is a SSD1963 chipbased TFT. The screen works using code with the UTFT library.

the question I am asking is there any way to get the ssd1963 screen to work with the original coding? is there a glue?

thanks

Well, the code seems to be on GitHub And it looks like it uses GFX style classes.

Yes, you can write a "GLUE" class to port GFX to UTFT. Or you can rewrite every GFX call to UTFT style.

Surely it is easier to just use a GFX compatible library rather than convert to UTFT. Either adapt the "TFTLCD.h" from your project or change to an existing SSD1963 GFX-style library. MCUFRIEND_kbv should be easy to use.

David.

David thanks for the prompt reply. I was looking earlier today at mcufriends,kvb. So I include mcufriends_kvb.h in he main program?

It is a little more complicated. You have to #define USE_SPECIAL and #define USE_MEGA_16BIT_SHIELD

I presume you are using a regular Mega2560 40-pin Adapter shield.

And you will need changes like tft.begin(0x1963) instead of tft.begin() There are also changes for a 5inch 800x480 or a 7inch 800x480.

As a silly question. Why are you not using a regular 240x400 screen e.g. ILI9326, ILI9327, SPFD5420, ST7783, R61509 instead of HX5352 ?

David.

David,

I have the adapter for the Arduino Due. Elechouse v2.1. I ordered the HX8352 400x240 from aliexpress but they sent a 5 inch ssd1963 based board. Cant send it back as it arrived and I didn't touch it for a month.'It is difficult sourcing another screen so i cant try with other screens.

If you have a CTE Adapter for Due, you use #define USE_DUE_16BIT_SHIELD Sainsmart have an exact copy of the ColdTears Adapter (with the added feature of bad soldering and incorrect jumpers)

I did not know that ElecHouse made a Due Adapter. I suggest that you make your own comparisons with the ColdTears doc. Post links and schematics if you are unsure of something.

David.

Hi David,
please see the attachment image of the adapter shield I have.

In which file do I insert the #define USE_DUE_16BIT_SHIELD?

Ehouse.jpg

Hi David, I read the mcufriend how to file and have the answer for my question.

It looks as if I have already written a SPECIAL: USE_ELECHOUSE_DUE_16BIT_SHIELD

Do you have a schematic? Google gets me nowhere.

If there is no schematic, you will have to test each pin for connectivity. Especially the /RD pin.

I would appreciate feedback from you. i.e. if you can test the USE_ELECHOUSE_DUE_16BIT_SHIELD for me.

David.

Hi David,
I have used this pin map attached to get the screen to function using the UTFT library. so I know the screen works.

Pin Mapping.pdf (63.4 KB)

David,
in mcufriend_special.h i have uncommented the #define USE_ELECHOUSE_DUE_16BIT_SHIELD. further down in the file there is this code.

(USE_ELECHOUSE_DUE_16BIT_SHIELD)  //ELECHOUSE_DUE shield on DUE
#warning USE_ELECHOUSE_DUE_16BIT_SHIELD
#define USES_16BIT_BUS
// configure macros for the control pins
#define RD_PORT PIOA
#define RD_PIN  15     //D24 Graham
#define WR_PORT PIOA
#define WR_PIN  14     //D23
#define CD_PORT PIOB
#define CD_PIN  26     //D22
#define CS_PORT PIOA
#define CS_PIN  7      //D31
#define RESET_PORT PIOC
#define RESET_PIN  1   //D33
// configure macros for data bus 
// DB0..DB7 on PIOC2..PIOC9,  DB8..DB15 on PIOC12..PIOC19
// 
#define CMASKH        (0xFF00<<4)
#define CMASKL        (0x00FF<<2)
#define CMASK         (CMASKH | CMASKL)
#define write_8(x)    { PIOC->PIO_CODR = CMASKL; PIOC->PIO_SODR = (((x)&0x00FF)<<2); }
#define write_16(x)   { PIOC->PIO_CODR = CMASK; \
                        PIOC->PIO_SODR = (((x)&0x00FF)<<2)|(((x)&0xFF00)<<4); }
#define read_16()     (((PIOC->PIO_PDSR & CMASKH)>>4)|((PIOC->PIO_PDSR & CMASKL)>>2) )
#define read_8()      (read_16() & 0xFF)
#define setWriteDir() { PIOC->PIO_OER = CMASK; PIOC->PIO_PER = CMASK; }
#define setReadDir()  { PMC->PMC_PCER0 = (1 << ID_PIOC); PIOC->PIO_ODR = CMASK; }
#define write8(x)     { write16(x & 0xFF); }
#define write16(x)    { write_16(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
#define READ_16(dst)  { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_8(dst)   { READ_16(dst); dst &= 0xFF; }

// Shield Control macros.
#define PIN_LOW(port, pin)    (port)->PIO_CODR = (1<<(pin))
#define PIN_HIGH(port, pin)   (port)->PIO_SODR = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))

Using the pin map I attached earlier do I change the code to

(USE_ELECHOUSE_DUE_16BIT_SHIELD)  //ELECHOUSE_DUE shield on DUE
#warning USE_ELECHOUSE_DUE_16BIT_SHIELD
#define USES_16BIT_BUS
// configure macros for the control pins
#define RD_PORT PIOA
#define RD_PIN  24     //D24 Graham
#define WR_PORT PIOA
#define WR_PIN  23     //D23
#define CD_PORT PIOB
#define CD_PIN    22   //D22
#define CS_PORT PIOA
#define CS_PIN  31      //D31
#define RESET_PORT PIOC
#define RESET_PIN  33   //D33
// configure macros for data bus 
// DB0..DB7 on PIOC2..PIOC9,  DB8..DB15 on PIOC12..PIOC19
// 
#define CMASKH        (0xFF00<<4)
#define CMASKL        (0x00FF<<2)
#define CMASK         (CMASKH | CMASKL)
#define write_8(x)    { PIOC->PIO_CODR = CMASKL; PIOC->PIO_SODR = (((x)&0x00FF)<<2); }
#define write_16(x)   { PIOC->PIO_CODR = CMASK; \
                        PIOC->PIO_SODR = (((x)&0x00FF)<<2)|(((x)&0xFF00)<<4); }
#define read_16()     (((PIOC->PIO_PDSR & CMASKH)>>4)|((PIOC->PIO_PDSR & CMASKL)>>2) )
#define read_8()      (read_16() & 0xFF)
#define setWriteDir() { PIOC->PIO_OER = CMASK; PIOC->PIO_PER = CMASK; }
#define setReadDir()  { PMC->PMC_PCER0 = (1 << ID_PIOC); PIOC->PIO_ODR = CMASK; }
#define write8(x)     { write16(x & 0xFF); }
#define write16(x)    { write_16(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
#define READ_16(dst)  { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_8(dst)   { READ_16(dst); dst &= 0xFF; }

// Shield Control macros.
#define PIN_LOW(port, pin)    (port)->PIO_CODR = (1<<(pin))
#define PIN_HIGH(port, pin)   (port)->PIO_SODR = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))

I sm thinking I hsve no CD pin and this is RS equivalent?

Chris

So it looks as if my SPECIAL is correct. Please confirm that graphictest_kbv works 100%. 1. it reads ID correctly as 0x1963 2. it displays text, colours, lines with no glitches 3. VERTICAL SCROLL works 4. SOFTWARE SCROLL works

Note that the Due is pretty speedy. You must watch the graphics carefully.

David.

p.s. Yes, CD_PIN is the same as RS, DC. i.e.Digital#22 or PB26 on the SAM3X Apart from the two defines, everything should work straight out of the box.

sorry David

how do i set up the graphictest_kvb.ino to call the mcufriend_special.h? do I comment out mcufriends_kvb.h?

// All the mcufriend.com UNO shields have the same pinout.
// i.e. control pins A0-A4.  Data D2-D9.  microSD D10-D13.
// Touchscreens are normally A1, A2, D7, D6 but the order varies
//
// This demo should work with most Adafruit TFT libraries
// If you are not using a shield,  use a full Adafruit constructor()
// e.g. Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h"// Hardware-specific library
#include <mcufriend_special.h> //is this correct??
MCUFRIEND_kbv tft;
//#include <Adafruit_TFTLCD.h>
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

my wife has given me 15 more minute to work on this tonight or its going in the bin when Im at work tomorrow

HI David

Serial took 0ms to start ID = 0x1963

this is the out put from the serial monitor. Just a white screen ATM but i haven't changed any of the code in the graphicstest_kbv,ino

just the two defines in mcrufriend_special.h and mcufriend_shield.h

is ther something I am missing>

No, it has read the ID correctly.
You do not need to change anything in the sketch.

You might need to change a line in MCUFRIEND_kbv.cpp.

//        table8_ads = SSD1963_480_regValues, table_size = sizeof(SSD1963_480_regValues);
        table8_ads = SSD1963_800_regValues, table_size = sizeof(SSD1963_800_regValues);
//        table8_ads = SSD1963_NHD_50_regValues, table_size = sizeof(SSD1963_NHD_50_regValues);
//        table8_ads = SSD1963_NHD_70_regValues, table_size = sizeof(SSD1963_NHD_70_regValues);
//        table8_ads = SSD1963_800NEW_regValues, table_size = sizeof(SSD1963_800NEW_regValues);
//        table8_ads = SSD1963_800ALT_regValues, table_size = sizeof(SSD1963_800ALT_regValues);

Try each table8_ads line. i.e. uncomment one line at a time. e.g. the SSD1963_NHD_50_regValues line

I suggest that you do this in the morning.

David.

David,

There was no change when I changed them one at a time. was i supposed to leave them uncommented on each try or was I to recomment them then move to the next line?

David
please see the attached compile log. I hope this helps also I have included the result from the LCD_IDreg too if it will help.

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 10 10 ID: ILI9320, ILI9325, ILI9335, …
reg(0x0004) 14 14 14 14 Manufacturer ID
reg(0x0009) 19 19 19 19 19 Status Register
reg(0x000A) 1A 1A Get Power Mode
reg(0x000C) 1C 1C Get Pixel Format
reg(0x0061) 71 71 RDID1 HX8347-G
reg(0x0062) 72 72 RDID2 HX8347-G
reg(0x0063) 73 73 RDID3 HX8347-G
reg(0x0064) 74 74 RDID1 HX8347-A
reg(0x0065) 75 75 RDID2 HX8347-A
reg(0x0066) 76 76 RDID3 HX8347-A
reg(0x0067) 77 77 RDID Himax HX8347-A
reg(0x0070) 70 70 Panel Himax HX8347-A
reg(0x00A1) B1 B1 B1 B1 B1 RD_DDB SSD1963
reg(0x00B0) B0 B0 RGB Interface Signal Control
reg(0x00B4) B4 B4 Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6 Display Control
reg(0x00B7) B7 B7 Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
reg(0x00C0) D0 D0 D0 D0 D0 D0 D0 D0 D0 Panel Control
reg(0x00C8) D8 D8 D8 D8 D8 D8 D8 D8 D8 D8 D8 D8 D8 GAMMA
reg(0x00CC) DC DC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00D4) D4 D4 D4 D4 Novatek ID
reg(0x00DA) DA DA RDID1
reg(0x00DB) DB DB RDID2
reg(0x00DC) DC DC RDID3
reg(0x00E0) F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 F0 GAMMA-P
reg(0x00E1) F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 GAMMA-N
reg(0x00EF) FF FF FF FF FF FF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control

compile_log.txt (28 KB)

Your SPECIAL is working correctly. The readID() has identified the SSD1963.

Do you have a link to the actual display that you have bought? Did the display come with any library or examples? Does it have a schematic?

Can you post link or photos?

There are several initialisation sequences. Only one should be used. i.e. all but one table8_ads statement should be commented.

David.

David, nothing came with the screen. It was purchased off Aliexpress the link is the following. https://www.aliexpress.com/item/3-2-inch-TFT-LCD-Shield-for-Arduino-DUE-TAIJIUINO-DUE-with-SD-and-Touch-control/1766514546.html?spm=a2g0s.9042311.0.0.aml3mI

however the screen that was delivered was a 5 inch display. it has the marking 5109B-SZ base of screen. i used the UTFT examples from the buydisplay.com website I came across. The elechouse website links dont work.