[SOLVED] Any way to improve ILI9486 SPI draw speed ? STM32F1

sajuukKahr
Sun Feb 19, 2017 9:31 pm
Hello all,

I am building a project based on a STM32F1 running at 72Mhz and a ILI9486 connected to SPI1, clock divider is 1 .
It is working quite well at the moment, my only concern is the slow draw times.
I am drawing images via 2 loops and drawPixel, library is https://github.com/stevstrong/Adafruit_ … ree/master based on the Adafruit GFX.

the times are:
timeSpendReadingFlash=191 millis
timeSpendRendering=1915 millis

this is for rendering:
1x 320×240
1x 320×45
1x 320×26
1x 320×21
1x 38×21
a total of 107038 pixels

Is there any way to speed this up ? a UI based on this solution is really sluggish.

What I tried:
Overclock the STM32 to 128mhz result: some small speed improvements but nothing special.


sajuukKahr
Sun Feb 19, 2017 9:47 pm
timeSpendReadingFlash=186
timeSpendRendering=2015
timeSpendSettingWindow=1652
timeSpendSettingColor=256

it seems that most of the time is spent setAddrWindow.
By the looks of it it seems that setAddrWindow sets a window of memory of 1 pixel at the time. Increasing the window to more pixels should in theory decrease the draw times.


stevestrong
Sun Feb 19, 2017 10:16 pm
This is it, 9 usecs wndow address setting for writing 1 pixel 1usec.
Try to write several pixels in the same block.
You could prepare first in memory the block to be written down to display.

sajuukKahr
Sun Feb 19, 2017 10:19 pm
Cheers, it seems I need to write a custom GFX on top of yours to serve my needs.

sajuukKahr
Sun Feb 19, 2017 11:44 pm
stevestrong wrote:This is it, 9 usecs wndow address setting for writing 1 pixel 1usec.
Try to write several pixels in the same block.
You could prepare first in memory the block to be written down to display.

sajuukKahr
Mon Feb 20, 2017 2:03 am
I had a look over SPIClass::write(const void *data, uint32 length) but it is just SPIClass::write(uint16 data) with a while loop

sajuukKahr
Mon Feb 20, 2017 2:24 am
SPI.setDataSize(DATA_SIZE_16BIT); cuts down the draw time for a fullscreen to
screenDraw=89

sajuukKahr
Mon Feb 20, 2017 2:52 am
Custom writeBuffer function

void SPIClass::writeBuffer(uint16_t *data, uint32_t length){
spi_reg_map * regs = _currentSetting->spi_d->regs;

for(uint32_t i; i<length i++){
// Serial3.print("index=");Serial3.println(tmp-length);
regs->DR = data[i]; // write the data to be transmitted into the SPI_DR register (this clears the TXE flag)
while ( (regs->SR & SPI_SR_TXE)==0 ) ; // wait till Tx empty
}
while ( (regs->SR & SPI_SR_BSY) != 0); // wait until BSY=0 before returning
}


stevestrong
Mon Feb 20, 2017 8:35 am
sajuukKahr wrote:
isn’t this what SPIClass::write(const void *data, uint32 length) is suppose to do ?

sajuukKahr
Mon Feb 20, 2017 8:56 am
stevestrong wrote:sajuukKahr wrote:
isn’t this what SPIClass::write(const void *data, uint32 length) is suppose to do ?

stevestrong
Mon Feb 20, 2017 9:15 am
sajuukKahr wrote: I tried to use it first but I honestly could not.

sajuukKahr
Mon Feb 20, 2017 5:46 pm
uint16_t tmpData[48] = {GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE,
GREEN, GREEN, GREEN, PURPLE, PURPLE, PURPLE};

uint16_t *p = tmpData;
SPI.write(p, 48);


stevestrong
Mon Feb 20, 2017 6:39 pm
Why don’t you use
SPI.write(tmpData, 48);

sajuukKahr
Tue Feb 21, 2017 12:49 am
Tried that at first same result.
I just wanted “extra measures” to make sure I did not mess something up.

It might be spi.c in the core as the SPI.c implementation seems fine will try to debug when I have free time.

Thanks for the help.

Quick question, OFFTOPIC: I am confronting myself with screen tearing (refresh of the screen hits when I am drawing the frame)…any idea how to avoid this ?


stevestrong
Tue Feb 21, 2017 8:40 am
Regarding the SPI functions, I replied in your other post.

The common display modules do not offer any screen refresh signals, so I don’t think you can do it without disassembling the module and hook the signals from the driver chip pins.


Leave a Reply

Your email address will not be published. Required fields are marked *