Skip to main content
Omar Suárez
Senior
April 18, 2017
Question

Nested interrupts - STM32F7

  • April 18, 2017
  • 4 replies
  • 1195 views
Posted on April 18, 2017 at 11:28

Hi,

I am trying to configure the STM32F7 to work with a Timer and a SPI to transfer data using DMA.

The idea is to use the TIM6 to trigger the SPI so I start the SPI data transmission inside the timer interrupt handler (HAL_TIM_PeriodElapsedCallback) and wait for the SPI transmission complete interrupt there.

After some test I found that the SPI transmission complete interrupt is not working and the problem seems to be the nested interrupts (SPI inside the TIM6 handler).

How should I configure the NVIC to make nested interrupts work?

Thanks in advanced,

Omar

#timer #interrups #nvic #stm32f7 #spi #dma
This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
April 18, 2017
Posted on April 18, 2017 at 14:21

You need to use the preemption levels (on the Cortex low numbers mean higher priority). You need to set the NVIC grouping so it supports the mix of preemption and sub-priorities you need. Here SPI must preempt TIM

The HAL has grave problems with blocking in interrupts, ie it is possible very easily to have code in interrupt handlers that spins unnecessarily, and has the potential to dead-lock. I would be very wary of such code, and the potential side-effects.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Omar Suárez
Senior
April 19, 2017
Posted on April 19, 2017 at 09:43

Thanks for help.

If I understood well then I should assign lower priority to SPI (DMA), so I did this for the DMA:

HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0,0);

HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);

and this for the TIM6:

HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 1,0);

HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);

But still doesn't work. The code is still waiting for DMA to complete the transfer indefinetely.

T J
Senior III
April 19, 2017
Posted on April 20, 2017 at 01:26

Hi,

you have to set flags under interrupt, and poll those flags in the foreground.

then you wont have any trouble.