Skip to main content
gerson74
Associate II
October 26, 2023
Solved

Interrupt priority in STM32F429

Good morning, I have some problems with interrupt priority on the STM32F429.
I set up a serial communication on UART1 with this priority

// USART
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init ( &NVIC_InitStructure );


I also set a TIM1 timer with this priority.

// TIM1
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init (&NVIC_InitStructure);


Although the serial priority is greater than the timer priority, if I am executing the timer interrupt routine (lasting about 200usec), I have verified that when I receive data via serial at 57600,N,8,1 (and therefore a byte every 156us ) the data is lost because it does not enter the serial interrupt routine.

Why does this happen?

 

Thank you

This topic has been closed for replies.
TDK
TDKBest answer
October 26, 2023

> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

The typical configuration has 4 bits for preemption and 0 bits for subpriority, which makes this setting invalid. Have you changed the defaults?

Perhaps show what NVIC_Init does. It's not a standard function as far as I can tell.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."

2 replies

TDK
TDKBest answer
October 26, 2023

> NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

The typical configuration has 4 bits for preemption and 0 bits for subpriority, which makes this setting invalid. Have you changed the defaults?

Perhaps show what NVIC_Init does. It's not a standard function as far as I can tell.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
gerson74
gerson74Author
Associate II
October 27, 2023

I solved it by calling the function

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);

before initialization!!

Thank you