ST7789V Mode selection for ST7789_t3 library

Maes2ro

Active member
I am developing an application that will use a 240 x 320 display from Microtips. This display employs an ST7789V control chip so it seems like a good idea to build my code with the 7789_t3 library. (I've attached the data sheet)

I have done a first version of the board, but can't get any display function so I am having some doubts about my design choices.

The display as supplied exposes all 4 MCU interface select pins, which allows a pretty wide range of mode options (see page 8 of the data sheet) including 5 serial types, but particularly confusing is the presence of a type II serial. I tried pretty hard to find out what this meant, but I guessed that II was newer and better :)

I was also not really sure whether the _t3 library was 3_line or 4_line (although my thinking is 3-line), so to hedge my bets I tied IM3 and IM2 high and gave myself jumpers for IM0 and IM1 so I could experiment. Sadly neither of the options seem to work.

It would be really helpful if you could give me some guidance on which mode the 7789_t3 library actually does support, and of course I realise I should have asked this first.

I'm using a Teensy 3.2 and running the module at 3.3V

Thanks very much for your help.
 

Attachments

  • 13-024QICB0GA1-S_V1.3_20200616.pdf
    1.2 MB · Views: 39
First - not sure what display you have, what sketch you are using or what your wiring is. The ST7789 320x240 display that we tested with was from Adafruit https://learn.adafruit.com/2-0-inch-320-x-240-color-ips-tft-display/overview and is 4-wire SPI and connected to the SPI pins.

if you are testing with the graphicstest.ino (recommeded) you will see that the connected pins are:
Code:
#define TFT_MISO  12
#define TFT_MOSI  11  //a12
#define TFT_SCK   13  //a13
#define TFT_DC   9 
#define TFT_CS   10  
#define TFT_RST  8

for that display I would be using:
Code:
ST7789_t3 tft = ST7789_t3(TFT_CS, TFT_DC, TFT_RST);
if using SPI and

uncomment this display option while making sure all other options are commented out.
Code:
  // OR use this initializer (uncomment) if using a 2.0" 320x240 TFT:
  //tft.init(240, 320);           // Init ST7789 320x240

Without more information can't help you much more than this.
 
Thank you very much for the speedy response. I'm using the graphicstest_ST7789 example that installs with the library, which doesn't have the MISO line implemented. This is the first part of my code. NB there are a few extra lines to set up and turn on the backlight. I'm also specifying the IO lines.

Code:
#include <Wire.h>
#include <PCA9533.h>

#include <Adafruit_GFX.h>    // Core graphics library
//#include <ST7735_t3.h> // Hardware-specific library
#include <ST7789_t3.h> // Hardware-specific library
#include <SPI.h>

// This Teensy3 native optimized version requires specific pins
//
#define TFT_SCLK 13  // SCLK can also use pin 14
#define TFT_MOSI 11  // MOSI can also use pin 7
#define TFT_CS    10  // CS & DC can use pins 2, 6, 9, 10, 15, 20, 21, 22, 23
#define TFT_DC   8  //  but certain pairs must NOT be used: 2+10, 6+9, 20+23, 21+22
#define TFT_RST   9  // RST can use any pin
#define SD_CS    20  // CS for SD card, can use any pin

// start dimmer
PCA9533 pca9533;

// Option 1: use any pins but a little slower
ST7789_t3 tft = ST7789_t3(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
//ST7789_t3 tft = ST7789_t3(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;


void setup(void) {

  //set up dimmer
  // Initialise I2C communication
  Wire.begin();
  // Initialise serial communication
  Serial.begin(115200);
  delay(1000);
  Serial.println("Starting device");
  // Setup PCA9533 and do some initial tests
  Serial.println("Setup LED Controller");
  // make sure device testing starts with default settings
  pca9533.init();
  Serial.println("Running init tests");
  Serial.print("Checking I2C Bus: ");
  Serial.println(pca9533.ping());
  pca9533.setMode(ALL_ON); //turn on backlight
  Serial.print("Backlight On ");

  // set up display
  pinMode(SD_CS, INPUT_PULLUP);  // don't touch the SD card
  Serial.print("hello from the display setup!");

  tft.init(240, 320);

  Serial.println("init display");

  uint16_t time = millis();
  tft.fillScreen(ST7789_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7789_BLACK);
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7789_WHITE);
  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

  // a single pixel
  tft.drawPixel(tft.width()/2, tft.height()/2, ST7789_GREEN);
  delay(500);

  // line draw test
  testlines(ST7789_YELLOW);
  delay(500);

  // optimized lines
  testfastlines(ST7789_RED, ST7789_BLUE);
  delay(500);

  testdrawrects(ST7789_GREEN);
  delay(500);

  testfillrects(ST7789_YELLOW, ST7789_MAGENTA);
  delay(500);

  tft.fillScreen(ST7789_BLACK);
  testfillcircles(10, ST7789_BLUE);
  testdrawcircles(10, ST7789_WHITE);
  delay(500);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}
 
You may want to test the display without trying to use the SD card or the PCA at the same time. Think that the issue is that you need to have the MISO line attached for the SD card to work. Never tried the SD Card on the display without a miso line.
 
Sorry I am sort of confused. Which is not all that unusual ;)

But I think you are asking about which Serial Mode, is applicable? I believe 4 wire Serial is what this library does:
That is it uses SCL and MOSI(DOUT), chip select (CS) and Data/Command (DC), these displays I don't believe do input back so MISO(DIN) I don't believe is used.
On some of the Adafruitand other displays, they do run MSIO and another Chip select pin for a SD card reader. Not sure if you have that or not.
 
Hi Kurt

You are quite correct. What I am trying to understand is whether the library is using 3 or 4 line serial, and whether it is 8 or 9 bit.
I am workng with a bare display rather than a breakout, so there is no SD card.
The Display offers the following serial modes, (and labels its serial lines SDA & SDO)

3-line 9bit Serial SDA in/out
4-line 8bit Serial SDA in/out
3-line 9bit Serial II SDA in / SDO out
4-line 8bit Serial II SDA in / SDO out

Studying the Sitronix data sheet I see that the two 4-line protocols expect the following data lines:
4-line 8bit Serial CS, D/C, CLK, SDA
4-line 8bit Serial II CS, D/C, CLK, SDA, SDO

The 3-line versions do not utilise D/C so I think it is reasonable to ignore these for this discussion. It's interesting that the 7789V chip clearly allows for data to be read though.

Getting back to my search for understanding of what the library is expecting; it seems that the most likely match is the 4-line 8bit Serial [CS, D/C, CLK, SDA], physically implemented as CS, D/C, CLK, MOSI. In which case I need to cut a track on my board :)

What do you think?
 
You have options...

To simply use the current libraries, you should switch to 4 wire and use the cs/dc/clk/SDO

If it can actually read data back, I did not see anything obvious in that pdf on the command set, but if they have something like ram read, then one could modify the code to do so. You can always hook up the MISO line either way.

For 3 wire, you probably build a version of the library that might support it. Where when each bytes is output over SPI, you might or in the right value to each byte as you push it onto the SPI fifo queue. The 3.2 does support I believe lengths between 4-16 bits. But I have never tried this. So have no idea how well it might work
 
Thanks for those thoughts Kurt.

Although it might be interesting, I have no particular need to explore the 3-wire option. All I want to do is get the 4-wire working.

I've checked the routing on my test board and it is practical to cut the track that currently holds the M3 mode line high, which will allow me to select the 4-line 8bit Serial (The display connects with a particularly tricky 45W 0.3mm pitch FFC connector)

Thanks for your help and I'll let you know how I get on.
 
Back
Top