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
Hello,

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) */
HAL_InitTick(TICK_INT_PRIORITY);

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

with:

#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?
Thanks

//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);
HAL_NVIC_EnableIRQ(TIM3_IRQn);
 
/* ADC */
HAL_NVIC_SetPriority(ADC_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(ADC_IRQn);
 
/* DMA-Stream */
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
 
/* Enable and set EXTI Line0 Interrupt  */
HAL_NVIC_SetPriority(EXTI0_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
 
/* Enable and set EXTI Line1 Interrupt  */
HAL_NVIC_SetPriority(EXTI1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(EXTI1_IRQn);

Outcomes