Skip to main content
Visitor II
August 26, 2025
Solved

I2C priorities in STM32U5

  • August 26, 2025
  • 3 replies
  • 430 views

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?

    This topic has been closed for replies.
    Best answer by mtuderan

    Don't worry about it. It got fixed. all good

    3 replies

    mtuderanAuthorAnswer
    Visitor II
    August 26, 2025

    Don't worry about it. It got fixed. all good

    Super User
    August 26, 2025

    What was the problem?

    mtuderanAuthor
    Visitor II
    August 27, 2025

    mtuderan_0-1756297775042.png

    this