[nRF52840 DK] SPI transaction interrupted by ISR ?

Hi,



I've got a display driven over SPI at 8MHz by the lib LVGL in a dedicated Zephyr thread and an ISR configured on one gpio pin that triggers a short routine registering the rising edge of the signal (basically incrementing a var).
 
The used Zephyr SPI write method is from <drivers/spi.h> :
static inline int spi_write_dt(const struct spi_dt_spec *spec, const struct spi_buf_set *tx_bufs);



When the ISR is highly solicited (i.e. lots of pulses on gpio pin -> >1k/s ), I've noticed the display starts to show artifacts that isn't cleared if the drawn area position isn't dynamic.

I'm assuming it comes from the case where the ISR is called in the middle of the display SPI update transaction and some SPI data is shifted out during this time as the SCK still continues from hardware.
 

Is there a way to make sure the SPI transaction doesn't "freeze" in this kind of configuration ?



Thanks for your time !
  • Finally, I managed to fix the issue by changing the driver implementation and using the lib : 

    #include <nrfx_spim.h>
    // instead of
    #include <drivers/spi.h>
    Doing so permitted to also specify a Data Control pin that nrf_spim will handle in one transaction (CMD + DATA in one tx buffer).
    This fixed the SPI sending sometimes the previous buffer data from the previous SPI tx call concatenated with the new data.
    The second issue was that the data filled by LVGL wasn't correct (some text character was disappearing on some frames) was fixed by compiling the used font without subpixel rendering.
Related