Skip to main content
Pavel A.
March 23, 2020
Solved

STM32H753. Stranger things...

  • March 23, 2020
  • 2 replies
  • 648 views

For a hour I'm breaking my head. How it this possible? What's going here?

unsigned max_prio = 5;
 __set_BASEPRI(max_prio);
 __DSB(); __ISB();
uint32_t basep = __get_BASEPRI();
printf("basepri=%u\n", basep); //>>>>>>>>>>>> it prints 0 !
 

Using the Atollic IDE, if this matters.

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

Only 4 bits of interrupt priorities are implemented, it means that only bits 7...4 are effective, bits 3...0 are always set to 0. Try it with 16, 32, etc.

Functions like NVIC_SetPriority take this into account, and shift the operand left with (8U - __NVIC_PRIO_BITS), but __set_BASEPRI doesn't.

2 replies

berendi
berendiBest answer
Principal
March 23, 2020

Only 4 bits of interrupt priorities are implemented, it means that only bits 7...4 are effective, bits 3...0 are always set to 0. Try it with 16, 32, etc.

Functions like NVIC_SetPriority take this into account, and shift the operand left with (8U - __NVIC_PRIO_BITS), but __set_BASEPRI doesn't.

Pavel A.
Pavel A.Author
March 23, 2020

Thank you Peter.