I have an SPI master-slave system with the slave being an STM32 running chibios.
Chibios doesn't support SPI slave mode, so I'm handling the hardware myself. No problem.
I have to implement the SPI protocol which is not ideal: after the master sends a byte the slave has to figure out what to send back during the following byte (frame). This cannot be done in advance, as the data depends on what the master sends.
So... all is fine and dandy, except that I also have an ADC running. The DMA complete interrupts from those cause enough delay to mess up the SPI protocol. I have already moved the processing of the ADC data to a thread and just wake up the thread instead of processing it in the callback. But still the interrupt overhead is too much. (My ADC callback is now taking 4 microseconds, in my current trace 8 microseconds are available, so the "tail" of the adc interrupt seems to be taking at least 4 microseconds too. )
Anyway... I want the SPI interrupts to have a higher priority than the ADC interrupts, so that the ADC interrupt is .... well... interrupted by the higher priority interrupt.
How can I achieve this? I have tried:
Code: Select all
#define STM32_ADC_ADC1_DMA_PRIORITY 1
#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 1
#define STM32_SPI_SPI1_IRQ_PRIORITY 2
#define STM32_SPI_SPI2_IRQ_PRIORITY 2

larger version: http://prive.bitwizard.nl/spi_vs_adc.png