STM32L4 CRITICAL SECTION
I use the following code to create critical section.
Is it correct?
I use the __get_PRIMASK() and __set_PRIMASK(primask_bit) from exemple codes.
Why are they needed?
Why disable is not sufficient?
Must I enable the IRQ after or is it done in the __set_PRIMASK()?
From the CubeMx, exemples with primask_bit = __get_PRIMASK(); and __disable_irq(); these lines are not followed by __enable_irq(), why?
Privilege mode is needed to disable irq, how could I know if it is the case?
primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */
__disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/
// my code ....
__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/Best regards
Mich
