AnsweredAssumed Answered

How to setup interrupts correctly

Question asked by Grimm.Martin on Oct 10, 2015
Latest reply on Oct 22, 2015 by thomas.robert.001

I've the following configuration on my STM32F4:
- ADC with DMA triggered from TIM3
- EXTI0 triggered from GPIO PA00
- EXTI1 triggered from GPIO PA01

The interrupt EXTI0 and EXTI1 should have the highes priority. Which means that it should called even if the MCU handles e.g. the ADC or the SysTick(). 

The standard configuration is a bit weired for me. In the CubeMX examples there is a configuration of the SysTick_IRQn of priority to 1. But actually in the HAL_Init() it is set to:

/* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */

/*Configure the SysTick IRQ priority */
 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0);


#define  TICK_INT_PRIORITY            ((uint32_t)0x0F) /*!< tick interrupt priority */
which seems a Preempt Priority of 15 ?!

Sometimes I get an HardFault error with my configuration. My code is in .cpp. There could be some HAL_Delay() issues I've read. Can anybody give me a hint with a correct interrupt configuration?

//HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);       // Is actually already done in HAL_Init()
/* System interrupt init                                */
/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
/* Timer 3 for ADC - Start */
HAL_NVIC_SetPriority(TIM3_IRQn, 2, 0);
/* ADC */
HAL_NVIC_SetPriority(ADC_IRQn, 2, 0);
/* DMA-Stream */
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 2, 0);
/* Enable and set EXTI Line0 Interrupt  */
HAL_NVIC_SetPriority(EXTI0_IRQn, 1, 0);
/* Enable and set EXTI Line1 Interrupt  */
HAL_NVIC_SetPriority(EXTI1_IRQn, 1, 0);