Skip to main content
MVart.2
Associate
July 21, 2022
Question

Using TouchGFX to drive multiple LCD displays

  • July 21, 2022
  • 13 replies
  • 3083 views

Hi All,

Are there any TouchGFX examples driving multiple displays over SPI using ILI9341 controller? I am able to drive a single 320x240 display no problem but run into issues when extending to two displays.

I'm guessing I am sending too much data over SPI but I am assuming that each SPI controller is independent so data sent over SPI1 should not affect data sent over SPI2?

I am using the following components:

ST NUCLEO-F767ZI

STM32CubeIDE v1.10.0

TouchGFX Designer 4.20.0

2.4" DisplayTech TFT (DT024CTFT) using ILI9341 Controller

Thanks,

Mike

This topic has been closed for replies.

13 replies

MM..1
Super User
July 22, 2022

When you use DMA for both SPI your bottleneck maybe is RAM and bus. If you prepare hw drivers for LCD ok i mean TouchGFX will not have issue.

MVart.2
MVart.2Author
Associate
July 23, 2022

Thanks for the reply. This could definitely be the bottleneck. I set up the code using CubeMX to have two independent SPIs connected to DMA. I configured the partial frame buffer to use 3 blocks of size 1920 bytes. Any suggestions on what I should change?

MM..1
Super User
July 23, 2022

Try 6 blocks and variate SPI speeds

MVart.2
MVart.2Author
Associate
July 23, 2022

Thanks for the suggestion on changing the number of blocks. I will give that a try. The fastest I could drive the SPI is 6.25 mbps with 3 blocks so I will let you know if that improves with 6 blocks. Thanks!

MVart.2
MVart.2Author
Associate
July 24, 2022

So I tried changing the blocks from 3 to 6 to 9 but it did not appear to improve performance. The code still appears to crash when I try to drive the SPI > 6mbps. I have seen videos where the displays are being driven way faster. Any other thoughts or suggestions to try? I really appreciate your help.

MM..1
Super User
July 24, 2022

Is your mbps bits or bytes per sec?

Work your code with one LCD?

MVart.2
MVart.2Author
Associate
July 24, 2022

bits per second

The code works fine with one LCD. I can even drive the LCD faster... I can set the SPI to 25mbps and the display appears to work fine...

The 2 LCD application takes the same pixel buffer and send to both screens inside the touchgfxDisplayDriverTransmitBlock() function.

MM..1
Super User
July 24, 2022

If you use two DMA SPI , you have two tranfer complete sources. But touchGFX system isnt prepared for this, you need change some code. Try show here how you do it now.

MVart.2
MVart.2Author
Associate
July 25, 2022

Thanks for the reply... Here is what I do... I override the two functions below...

void touchgfxDisplayDriverTransmitBlock(uint8_t* pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
 {
 	isTransmittingData = 1;
 
 	ILI9341_SetWindow(x, y, x+w-1, y+h-1, 0, &hspi1);
 	ILI9341_SetWindow(x, y, x+w-1, y+h-1, 1, &hspi2);
 
	ILI9341_DrawBitmap(w, h, pixels, 0, &hspi1);
 	ILI9341_DrawBitmap(w, h, pixels, 1, &hspi2); 
}
  
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi) 
{ 
	if (hspi->Instance == SPI1) {
 		spi1done = 1; 
	}
 
	if (hspi->Instance == SPI2) {
 		spi2done = 1;
 	}
 
	if (spi1done + spi2done == 2) {
		spi1done = 0; 
		spi2done = 0;
 
		ILI9341_EndOfDrawBitmap();
 		isTransmittingData = 0;
 		DisplayDriver_TransferCompleteCallback(); 
	}
}

I can share my project with you if that makes it easier?

MM..1
Super User
July 25, 2022
Your code do mirroring, why two SPI?
I mean your idea is independent extend H or V.
Try reorder commands in transmitblock set 1 – draw 1 – set 2 – draw 2 and in set ofcourse cant be used DMA.
MVart.2
MVart.2Author
Associate
July 25, 2022

The mirroring is just for testing. I needed something simple to test driving two displays. You are correct. Eventually I will have independent data going to both displays. The plan is to extend the H.

Thanks for the suggestion. I will try reordering the commands in the transmit block. Yes. The set commands are not using DMA, just the pixel data.

MM..1
Super User
July 26, 2022
If extend, your code must be more complex. Cant wait for both callbacks usw.
Too for optimize full screen refresh maybe need be writed own code, because TGFX do it in linear sequence, then not use both SPIs power.
Max speed for SPI is defined in LCD pdf as clock 10-50MHz on ILI min 100ns = 10MHz max 10mbps.
MVart.2
MVart.2Author
Associate
July 26, 2022

Thanks again for your continued support. Any suggestions on how to improve upon waiting for two callbacks?

I have optimized the ILI9341_SetWindow and ILI9341_DrawBitmap to combine SPI1 and SPI2 with little improvement.

Is there another LCD controller you would recommend? I have searched for others and have found slightly faster serial write cycle of 66ns...