Hi,
I read a lot of discussions about SPI interrupts (or ESP32 external interrupts in general), and I wonder if there are guide lines to use multiple sensors with SPI interface working with interrupts.
Practically I use the RFM69 transceiver which generates an interrupts when a RF frame is received. With the current (official) library SPI transfer handling is done in the Interrupt routine itself, which is causing a variety of crashes.
As I understand the OS is also using SPI to access the Memory.
So I did rework this library as the RMF69X (see github) by limiting the SPI interrupt to the setting of a flag and handle the SPI transfer as a normal routine, which looks to be OK (but I didn't really made some extensive tests).
Some people using it claims that in some cases there is a clash with the memory access.
So I am looking for a flag such a "SPI has interrupt" or "SPI has transaction" variables (like ones of the Arduino library), or any form of synchronization method between several asynchronous SPI access and the one used by the OS, to improve the RFM69X library.
Any ideas or explanations are welcome
Thanks in advance
Robert
How to synchronise multiple SPI interupts
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to synchronise multiple SPI interupts
The way to do this is to use the features of FreeRTOS. Create a semaphore and a separate thread for SPI handling. In the thread, wait for the semaphore to be set. In the interrupt, set the semaphore. The RTOS will make sure your thread is not ran when it doesn't need to be.
Wrt spi-to-access-memory: The ESP32 has 4 SPI peripherals. The first two are used for memory accesses, and as such unavailable to the SPI driver. This means that when you use the SPI driver, you don't need to worry about interfering with memory accesses.
Wrt spi-to-access-memory: The ESP32 has 4 SPI peripherals. The first two are used for memory accesses, and as such unavailable to the SPI driver. This means that when you use the SPI driver, you don't need to worry about interfering with memory accesses.
Re: How to synchronise multiple SPI interupts
Thank-you for your answer.
I don't plan to dig into the FreeRTOS code which e is above my capacities. However I think I understand the way I will be able to implement the semaphore technique that you have mentioned.
Robert
I don't plan to dig into the FreeRTOS code which e is above my capacities. However I think I understand the way I will be able to implement the semaphore technique that you have mentioned.
Robert
Who is online
Users browsing this forum: No registered users and 114 guests