Slow SPI performance with zephyr

SDK Environment: nRF Connect SDK v1.7.1

Target: Decawave DWM1001-DEV. This uses the nRF52832

A 5 byte SPI transfer is taking about 17us when using the nordic spim drivers and about 56us when using the zephyr spim drivers.

SPI CLK frequency = 8M

Would this be considered normal? The slow speed of the zephyr SPI drivers is causing problems in my application.

The zephyr drivers seem to be stable, but slow.

I set and clear a gpio testpin before and after the SPI transfer so I can measure the timing.

SPI timing with the nordic drivers

SPI timing with the zephyr drivers

"nrfx_spim.zip" uses the nordic drivers

"zephyr_spim.zip" uses the zephyr drivers

6763.nrfx_spim.zipzephyr_spim.zip

  • Any thoughts on this?

    I would rather use the zephyr drivers as I am having occasional reliability problems with my use of the Nordic drivers.  See nrfx_spim-driver-sometimes-does-not-call-the-event-handler

  • Hi Again

    Sorry for the late reply, I have tested the sample project, using the original branch of Zephyr project (https://github.com/zephyrproject-rtos/zephyr), which is usually ahead of the mirror of Zephyr which is used in the nordic sdk. So I can say the last modification of Zephyr has been considered.

    Because only I had access to nrf52833dk, then I have made some minor changes in order to run the sample on my hardware, And here you can find the result:

    The time between when Chip selector is enabled until when SPI-CLK starts, is about 5us, and the time between when SPI-CLK stops until when the chip selector has disabled, is about 17us, so very close to what you have seen before. I can say it is the normal operation of last Zephyr driver and maybe it could be improved. You can report the problem into the Zephyr's github page.

    Also I tried to disable the "chip selector" functionality of Zephyr's driver by setting the pointer to NULL and trying to toggle the corresponding pin manually, but the result was similar. Actually "spi_transceive" function returns after a delay, despite of the "chip select" functionality.

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

    PS: to measure the time of running a function or some line of the code, you can use the built-in api of Zephyr instead of toggling a gipo and measuring by the external tools. You can find more information here:

    https://docs.zephyrproject.org/latest/reference/timing_functions/index.html

    Regards,

    Saleh

Related