fast SPI transfer in periodic ISR

lhm000
Posts: 1
Joined: Sat Feb 24, 2024 12:42 pm

fast SPI transfer in periodic ISR

Postby lhm000 » Sat Feb 24, 2024 12:59 pm

I am using the ESP32-S3 on a custom designed board. I generate a periodic interrupt with the General Purpose Timer. The frequency is up to 38 kHz (every 26 µs). Within the ISR I would like to push out data with octal SPI. I am using the SPI Master Driver.

I am struggling with getting SPI to work within the ISR at all. It works well in the main loop, but not within the timer generated ISR. What could be the reason?

Furthermore, it looks like the SPI controller is very slow. It takes about 10µs, until data transfer starts. The latency is not constant and varies widely.

What is the reason for the slow response? Is there a way to speed up reaction time significantly?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: fast SPI transfer in periodic ISR

Postby ESP_Sprite » Sun Feb 25, 2024 1:21 am

You can't do too much in an ISR, specifically not any blocking function. The FreeRTOS way to do this would be to use an inter-task communication method (e.g. a semaphore or task notification) to unblock a high-priority task that then does the sending.

The SPI driver is written for universality and data throughput, not latency - but you can try polling requests and acquiring the bus permanently if you want to try getting the latency down.

Who is online

Users browsing this forum: No registered users and 114 guests