5 LCDs on one SPI bus with the library ST7789_t3.h on Teensy 3.5

jondibar

Member
Hi!

I have just got an 2'' 240x320 TFT display(EA TFT020-23AINN) working on a Teensy 3.5 using the T3/4 optimised library.

My goal is to be able to drive 5 of these ST7789 displays from the same Teensy 3.5 on the same SPI bus. Because the remaining pins are already used for other purposes, I have to limit myself to an SPI bus.
At the moment I have the test programme below. A very simple program that controls 2 LCDs and outputs 3 lines in the loop, not optimised, a proof of cancept. I have several CS pins, the same DC and RST pin.
It compiles in the Arduino 2.0.3 IDE and runs also on the Teensy. But only one LCD works, the LCD that was last tftX.init(), therefore tft2.
The signals on my osciloscope look fine. The CS pins goes LOW one after the other and the MOSI also sends signals in this time. So one LCD gets the Data but dont give it out.

I'm new to this but my current thinking is that my options might be:

1) The SCK highestpoint is 2V. Maybe to low? But One LCD works so idk.

2) The library does not support multiple LCDs on one SPI bus.

3) One of the LCDs is initialised incorrectly and cannot read the data that comes in.

Does anyone have any thoughts on whether one of these strategies might work, or reasons why one or more can be ruled out, or perhaps another even better option? I am aware there are going to be speed considerations with sharing SPI busses for two devices. The displays will generally just be holding static texts for a while, not constantly updating, so I'm not too concerned. The processor will be doing almost nothing else.

This forum post describes a similar problem but I can't figure out what the answers are.

Thanks in advance for your thoughts!

-Jonas

Code:
#include <ST7735_t3.h> // Hardware-specific library
#include <ST7789_t3.h> // Hardware-specific library
#include <SPI.h>

#define TFT_CS1        2
#define TFT_CS2        3
#define TFT_RST       10
#define TFT_DC         8


ST7789_t3 tft1 = ST7789_t3(TFT_CS1, TFT_DC, TFT_RST);
ST7789_t3 tft2 = ST7789_t3(TFT_CS2, TFT_DC, TFT_RST);


void setup() {
  //init LCDs
  tft1.init(240, 320);           // Init ST7789 320x240
  tft2.init(240, 320);           // Init ST7789 320x240

  tft1.fillScreen(ST77XX_BLACK);
  tft2.fillScreen(ST77XX_BLACK);
}


void loop() {
  tft1.setCursor(15, 30);
  tft1.fillScreen(ST7735_BLACK);
  tft1.println("I am tft1");


  tft2.setCursor(15, 30);
  tft2.fillScreen(ST7735_BLACK);
  tft2.println("I am tft2");
  delay(1000);


  tft1.setCursor(30, 100);
  tft1.println("01099");

  tft2.setCursor(30, 100);
  tft2.println("56432");
  delay(1000);


  tft2.setCursor(30, 200);
  tft2.println("0987864");


  tft1.setCursor(30, 200);
  tft1.println("2828");
  delay(1000);
}
 
Since you're using a common Reset PIN (TFT_RST), all LCD displays get reset several times, once per tftX.init() call.

I'm driving six LCD displays with a Teensy 4.1 from a common SPI without difficulty. In my case I pass "0xff" as the TFT_RST on the instantiation, then execute my own reset before calling the tftX.init() function.
Something like:
Code:
#define TFT_CS0		29
#define TFT_CS1		28
#define TFT_CS2		27
#define TFT_CS3		26
#define TFT_CS4		25
#define TFT_CS5		24
#define TFT_DC		39
#define TFT_RST		38
#define TFT_RST_DUMMY	0xff

ST7735_t3 Tft0 = ST7735_t3(TFT_CS0, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 Tft1 = ST7735_t3(TFT_CS1, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 Tft2 = ST7735_t3(TFT_CS2, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 Tft3 = ST7735_t3(TFT_CS3, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 Tft4 = ST7735_t3(TFT_CS4, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 Tft5 = ST7735_t3(TFT_CS5, TFT_DC, TFT_RST_DUMMY);
ST7735_t3 *Tfts[6] = { &Tft0, &Tft1, &Tft2, &Tft3, &Tft4, &Tft5 };


 void disp_init()
{
    ST7735_t3 *tft;
    int i;

    /* reset the displays */
    pinMode(TFT_RST, OUTPUT);
    digitalWriteFast(TFT_RST, HIGH);
    delay(100);
    digitalWriteFast(TFT_RST, LOW);
    delay(100);
    digitalWriteFast(TFT_RST, HIGH);
    delay(200);
    /* initialize the displays */
    for (i=5; i>=0; i--) {
	tft = Tfts[i];
	tft->init(240, 320);
    }
}
 
Back
Top