cancel
Showing results for 
Search instead for 
Did you mean: 

I2C priorities in STM32U5

mtuderan
Visitor

Hi,

 

I have been working with a STM32U575 MCU and something strange has happened that I spent a lot of time trying to find the root cause for it and I am not able to understand what is wrong.

I work with I2C slave interrupts and have FreeRTOS running. I realized FreeRTOS gets stuck in checking priorities when a FromISR function is called from the I2C handler.

Long story short, checking all the configs many times, I checked what are the priority of the IRQs?

 

 

HAL_NVIC_SetPriority(I2C1_EV_IRQn, NVIC_IRQ_PRIOR_I2C_SLAVE_EV, NVIC_IRQ_SUB_PRIOR_I2C_SLAVE_EV);
HAL_NVIC_SetPriority(I2C1_ER_IRQn, NVIC_IRQ_PRIOR_I2C_SLAVE_ER, NVIC_IRQ_SUB_PRIOR_I2C_SLAVE_ER);
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
PRINT("I2C1_EV raw priority: %lu\n", NVIC_GetPriority(I2C1_EV_IRQn));
PRINT("I2C1_ER raw priority: %lu\n", NVIC_GetPriority(I2C1_ER_IRQn));
PRINT("__NVIC_PRIO_BITS = %d\n", __NVIC_PRIO_BITS);
PRINT("configPRIO_BITS = %d", configPRIO_BITS);

 

having these in my .h file.

 

#define NVIC_IRQ_PRIOR_I2C_SLAVE_ER         6
#define NVIC_IRQ_PRIOR_I2C_SLAVE_EV         6


#define NVIC_IRQ_SUB_PRIOR_I2C_SLAVE_ER     0
#define NVIC_IRQ_SUB_PRIOR_I2C_SLAVE_EV     0

 

and what I get is 

 

 

I2C1_EV raw priority: 0
I2C1_ER raw priority: 6
__NVIC_PRIO_BITS = 4
configPRIO_BITS = 4

 

why one of them is set to 6 and the other is 0?

0 REPLIES 0