We always have the following code to make sure that only the interrupts with higher priority than 0x20 will wake up the processor.
PRIMASK = 1
BASEPRI = 0x20
PRIMASK = 0
But I think if we’re in the critical section (PRIMASK==1) and even call 'BASEPRI=0x20’, the execution priority, which is the final boosted priority, at this moment should be 0 but not 0x20 refer to the below snapshot from <DDI0403E_d_armv7m_arm>.
Hence I’m confused why other interrupts could take the processor out of WFI as the highest priority of them is 0, which is the same as the current priority?
Please kindly correct me if my understanding is wrong.
When a processor issues a WFI instruction it can suspend execution and enter a low-power state. It can remain in that state until the processor detects one of the following WFI wakeup events:• A reset.• An asynchronous exception at a priority that, if PRIMASK was set to 0, would preempt any currently active exceptions.Note The processor ignores the value of PRIMASK in determining whether an asynchronous exception is a WFI wakeup event.• If debug is enabled, a debug event.• An IMPLEMENTATION DEFINED WFI wakeup event.
Maybe the last point applies?
Actually, I don't know so I create this thread to ask for help.
I could find similar scenarios as the code with google, but they focus on whether the ISR will be executed but not the execution priority.
For the 'Note' part in the text segment you provided, it also makes me confused when I read the document. How does the processor ignore the PRIMASK as needing it to determine whether an exception would preempt any current active exceptions?
And I could find this design on many vendors, so maybe not an IMPLEMENTATION DEFINED?
Which SoC are you using? Check its manual.
An STM32 manual says, any enabled interrupt will wake up the core.
Also the STM32.
I just want to confirm if this is the 'An IMPLEMENTATION DEFINED WFI wakeup event' or 'An asynchronous exception at a priority that, if PRIMASK was set to 0, would preempt any currently active'.
Anyway, it's so nice for your help.
View all questions in Cortex-M / M-Profile forum