Page 1 of 1

ILI9341 -> SPI is very slow

Posted: Fri Mar 22, 2019 1:50 pm
by TuxuT_ESP32
Hi guys,

I guess I need your help with the SPI interface.
I downloaded a current master branch of the esp-idf and included the LCD component from the ESP IoT Solution which included/wrapped the Adafruit GFX Library (esp-iot-solution/components/spi_devices/lcd/) to drawing text string to my ILI9341 LCD Display.

This was a very straight forwarded way and my code build successfully.
BUT: Writing to the display seems very very slow at this moment. Currently I don't know why. If I writing a string to the display, I can see building up the text character by character on the display. This is a wrong behaviour.

I uses the following code to initilialize the LCD and getting a lcd_obj object to access the display:

Code: Select all

void initialise_lcd(void)
{
    /*Initialize LCD*/
    lcd_conf_t lcd_pins = {
        .lcd_model    = LCD_MOD_ILI9341,
        .pin_num_miso = GPIO_NUM_12,   // leave unconnected
        .pin_num_mosi = GPIO_NUM_13,   
        .pin_num_clk  = GPIO_NUM_14,   
        .pin_num_cs   = GPIO_NUM_15,   
        .pin_num_dc   = GPIO_NUM_26,   // better 35
        .pin_num_rst  = GPIO_NUM_25,   // better 34
        .pin_num_bckl = GPIO_NUM_17,  // leave unconnected
        .clk_freq     = 40 * 1000 * 1000,
        .rst_active_level = 0,
        .bckl_active_level = 0,
        .spi_host = HSPI_HOST,
        .init_spi_bus = true,
    };

    if (lcd_obj == NULL) {
        lcd_obj = new CEspLcd(&lcd_pins);
    }
    
    // write test
    lcd_obj->setRotation(2);
    lcd_obj->fillScreen(COLOR_ESP_BKGD);
    lcd_obj->setTextSize(1);

    lcd_obj->setTextColor(COLOR_GREEN, COLOR_ESP_BKGD);
    lcd_obj->setFont(&FreeSans9pt7b);
    lcd_obj->drawString("HELLO WORLD",                        3, 40);
} 

The SPI device should run with 40MHz and should use the HW SPI of the ESP32 device.

Please did you have any idea what is my mistake?
Thank you very much,
Stefan

Re: ILI9341 -> SPI is very slow

Posted: Wed Mar 27, 2019 8:59 am
by shansted
Have you tried using a slower SPI , say 10Mhz. The example code uses 10mhz or 26mhz.
https://github.com/espressif/esp-idf/bl ... ple_main.c

Re: ILI9341 -> SPI is very slow

Posted: Tue Mar 02, 2021 3:51 pm
by bembite
I have ported custom graphic library for lcd displays on esp32, I am using hw spi as in the example provided with esp-idf. The speed(not freq) of filling screen is super low. I tried 26MHz and 10MHz config, the esp32 seems to be the slowest mcu I tried for my lib. Can't figure out what is happening!

Re: ILI9341 -> SPI is very slow

Posted: Wed Mar 03, 2021 1:47 am
by ESP_Sprite
The ESP32 can be pretty fast wrt SPI using its internal DMA capability, however this speed only kicks in with large transactions (that is, loads of data to be sent in one go with CS only going low once). If your graphic library e.g. does one SPI transaction for each pixel it sets, it's going to be really slow, and you may want to add some caching or rework the display controller logic in it.