This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GFX example very slow - nRF52840

I am working on a new design and i am using ST7789 (240 X 320 pixels) screen with nRF52840, it is working fine. I have followed the code provided in SDK example (big thanks).

But it is painfully slow, is there a way to make it faster considering nRF52840 has a powerful processor and good memory.

Any guidance will be much appreciated. Due to cost and complexity i wanted not to use a secondary processor.

  • Hi

    The nrfx_spim example uses the extended features of SPI. Can you try to enable NRFX_SPIM_EXTENDED_ENABLED in the sdk_config.h file and set the frequency to spi_config.frequency = NRF_SPIM_FREQ_32M;

    Keep in mind that you need to use SPIM instance 3 (SPIM3) in order to support the 16 or 32 MHz frequencies. 

    Best regards,

    Simon

  • Hi Simonr,

    I tried by updating code as shown below, but after updating it stopped working. What is it that i am doing wrong?

    -->ST7789.c

    ---------------------------------

    #include "nrfx_spim.h"

    #define SPI_INSTANCE 3
    static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);

    //static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ST7735_SPI_INSTANCE);

    static ret_code_t hardware_init(void)
    {
    ret_code_t err_code;

    nrf_gpio_cfg_output(ST7789_DC_PIN);

    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
    spi_config.frequency = NRF_SPIM_FREQ_32M;
    spi_config.ss_pin = ST7789_SS_PIN;
    spi_config.miso_pin = ST7789_MISO_PIN;
    spi_config.mosi_pin = ST7789_MOSI_PIN;
    spi_config.sck_pin = ST7789_SCK_PIN;
    //spi_config.dcx_pin = NRFX_SPIM_DCX_PIN;
    spi_config.use_hw_ss = true;
    spi_config.ss_active_high = false;
    APP_ERROR_CHECK(nrfx_spim_init(&spi, &spi_config, NULL, NULL));
    return err_code;
    }

    -->pca10056\blank\config\sdk_config.h

    ---------------------------------

    #ifndef NRFX_SPIM3_ENABLED
    #define NRFX_SPIM3_ENABLED 1
    #endif

    #ifndef NRFX_SPIM_EXTENDED_ENABLED
    #define NRFX_SPIM_EXTENDED_ENABLED 1
    #endif

  • Hi

    Do you see any errors when compiling/building? At first glance, I'm not able to spot what's wrong in your init function. You should be able to see an error either in when compiling or by debugging the application.

    Best regards,

    Simon

  • There are no error on compilation. Just the screen does not render anything.

    To double check, does it mean when using SPIM (NRFX_SPIM_EXTENDED_ENABLED) spi will work faster?

    I see in current gfx project SPI_ENABLED i will disable it and just use NRFX_SPIM_ENABLED i will give it a try today.

    // <e> SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer
    //==========================================================
    #ifndef SPI_ENABLED
    #define SPI_ENABLED 1
    #endif

    // <e> NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver
    //==========================================================
    #ifndef NRFX_SPIM_ENABLED
    #define NRFX_SPIM_ENABLED 1
    #endif
    // <q> NRFX_SPIM0_ENABLED - Enable SPIM0 instance

    #ifndef NRFX_SPIM3_ENABLED
    #define NRFX_SPIM3_ENABLED 1
    #endif

  • Hi

    Any luck on your end? You can check out my colleague Jimmy's blog post on how to use the SPI Master and slave in the nRF52 series. The guide explains how to use the SPIM3 with the DCX/DC pin which is required when using SPIM_EXTENDED_ENABLED.

    Best regards,

    Simon

Related