Dear Hardware/Arduino Gods,
I need help with my display to get it up and running.
I'm using ESP32 Dev module in Arduino with the display -
The display is 3 wire SPI, with 9 bits, ST7789V.
There is no Command/Data signifying line. That data is added as MSB, i.e. the 9th bit before the command/Data byte.
I am using the Adafruit's library but I have modified it. I checked the display, it's working on some other processor, unfortunately, I don't have the code for it.
Here is the code that I have modified in Adafruit library -
Following is the code I'm using to initialize the display, ie its the driver supplied by the manufacturer.
void Adafruit_ST77xx::InitDisplay(){
spiWriteCMD9thBitFor3Wire (0x11);
delay(120); //Delay 120ms
//-------------------------------display and color format setting-----------------------------//
spiWriteCMD9thBitFor3Wire (0x36);
spiWrite (0x00);
spiWriteCMD9thBitFor3Wire (0x3A);
spiWrite (0x06);// #06
//--------------------------------ST7789S Frame rate setting----------------------------------//
spiWriteCMD9thBitFor3Wire (0xB2);
spiWrite (0x0C);
spiWrite (0x0C);
spiWrite (0x00);
spiWrite (0x33);
spiWrite (0x33);
//spiWriteCMD9thBitFor3Wire (0xB7);
//spiWrite (0x75);//check this, other try 34, 35, 70
//---------------------------------ST7789S Power setting--------------------------------------//
spiWriteCMD9thBitFor3Wire (0xBB);
spiWrite (0x1A);// other - 1c, 2B, 35
spiWriteCMD9thBitFor3Wire (0xC0);
spiWrite (0x2C);
spiWriteCMD9thBitFor3Wire (0xC2);
spiWrite (0x01);
//added by crystal-
spiWrite (0xFF);
//end
spiWriteCMD9thBitFor3Wire (0xC3);
spiWrite (0x0F);//others
spiWriteCMD9thBitFor3Wire (0xC4);
spiWrite (0x20);
spiWriteCMD9thBitFor3Wire (0xC6); //frame rate
spiWrite (0x0F);
spiWriteCMD9thBitFor3Wire (0xD0);
spiWrite (0xA4);
spiWrite (0xA1);
//--------------------------------ST7789S gamma setting---------------------------------------//
spiWriteCMD9thBitFor3Wire (0xE0);
spiWrite (0xD0);
spiWrite (0x13);
spiWrite (0x1A);
spiWrite (0x0A);
spiWrite (0x0A);
spiWrite (0x26);
spiWrite (0x3F);
spiWrite (0x54);
spiWrite (0x54);
spiWrite (0x18);
spiWrite (0x14);
spiWrite (0x14);
spiWrite (0x30);
spiWrite (0x33);
spiWriteCMD9thBitFor3Wire (0xE1);
spiWrite (0xD0);
spiWrite (0x13);
spiWrite (0x1A);
spiWrite (0x0A);
spiWrite (0x0A);
spiWrite (0x26);
spiWrite (0x3F);
spiWrite (0x54);
spiWrite (0x54);
spiWrite (0x1A);
spiWrite (0x16);
spiWrite (0x16);
spiWrite (0x32);
spiWrite (0x35);
spiWriteCMD9thBitFor3Wire (0x29);
}
Following are the functions I'm using to write the 9 bits command or data -
- For command write -
void Adafruit_SPITFT::spiWriteCMD9thBitFor3Wire(uint8_t b) {
if(_sclk < 0){
HSPI_WRITE(b);
return;
}
SSPI_MOSI_LOW(); // since its a command, so low
SSPI_SCK_LOW(); // Clock it in
SSPI_SCK_HIGH();
// Now send the remaining 8 bits
for(uint8_t bit = 0x80; bit; bit >>= 1){
if((b) & bit){
SSPI_MOSI_HIGH();
} else {
SSPI_MOSI_LOW();
}
SSPI_SCK_LOW();
SSPI_SCK_HIGH();
}
}
and the Data write -
void Adafruit_SPITFT::spiWrite(uint8_t b) {
if(_sclk < 0){
HSPI_WRITE(b);
return;
}
SSPI_MOSI_HIGH(); // since its a Data, so HIGH
SSPI_SCK_LOW(); // Clock it in
SSPI_SCK_HIGH();
for(uint8_t bit = 0x80; bit; bit >>= 1){
if((b) & bit){
SSPI_MOSI_HIGH();
} else {
SSPI_MOSI_LOW();
}
SSPI_SCK_LOW();
SSPI_SCK_HIGH();
}
}
I have made relevant changes in the library to call these functions, the code compiles properly, but the screen doesn't show anything. Its blank sort of. Please check image -
The wiring is correct as per the datasheet of the display, see attachment. I have externally attached 1K Ohm pull-up resistors to SDA and SCLK lines as well (Not shown in the attachment).
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
#define TFT_MOSI 23
#define TFT_SCLK 18
#define LCD 13 // to power ON/Off the LCD
I'm not sure where is the fault, I feel may be the 9bit code that I'm sending out is the issue here, it doesn't look like it, but maybe?
Do I need 1K pull up resistors for SCL and SDA lines? I'm lost and any help is greatly appreciated.
PS - This is my first post here, so please be gentle with me if I have overlooked the forum posting codes.





