Arm Community
Site
Search
User
Site
Search
User
Groups
Education Hub
Distinguished Ambassadors
Open Source Software and Platforms
Research Collaboration and Enablement
Forums
AI and ML forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Arm Virtual Hardware forum
Automotive forum
Compilers and Libraries forum
Graphics, Gaming, and VR forum
High Performance Computing (HPC) forum
Infrastructure Solutions forum
Internet of Things (IoT) forum
Keil forum
Morello forum
Operating Systems forum
SoC Design and Simulation forum
SystemReady Forum
Blogs
AI and ML blog
Announcements
Architectures and Processors blog
Automotive blog
Graphics, Gaming, and VR blog
High Performance Computing (HPC) blog
Infrastructure Solutions blog
Internet of Things (IoT) blog
Operating Systems blog
SoC Design and Simulation blog
Tools, Software and IDEs blog
Support
Arm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Support forums
Architectures and Processors forum
Cortex-M4: guaranteed wakeup from WFI?
Jump...
Cancel
State
Accepted Answer
+1
person also asked this
people also asked this
Locked
Locked
Replies
9 replies
Subscribers
348 subscribers
Views
16078 views
Users
0 members are here
Cortex-M
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Cortex-M4: guaranteed wakeup from WFI?
Markus Grabner
over 11 years ago
Note: This was originally posted on 8th August 2013 at
http://forums.arm.com
Hi all!
I'm wondering how to ensure that the Cortex-M4 is always woken up on an interrupt from the WFI instruction when executing code like this:
__disable_irq();
// do something ...
__enable_irq();
__WFI();
If an interrupt is triggered between __enable_irq() and __WFI(), the interrupt handler is processed [font="Arial"]immediately and completed before [/font][font="Courier New"]__WFI() is executed, i.e., [/font][font="Arial"][font="Courier New"]__WFI()[/font] will wait for the next interrupt such that the first one is effectively lost. The ATmega* processors have a very simple solution to this problem: enabling interrupts is always delayed by one clock cycle such that the processor can safely enter sleep mode before interrupts can occur and wake up the processor. Thereby it is guaranteed that the processor is always woken up on an interrupt. How is this done on the Cortex-M4? As far as I know, there is no such enable interrupt delay, or is there a totally different mechanism to ensure wakeup on interrupts?
Thanks & kind regards,
Markus
P.S.: A lengthy discussion on a similar topic is
here
, though in German language.
[/font]
Top replies
Martin Weidmann
over 11 years ago
+1
verified
Note: This was originally posted on 9th August 2013 at http://forums.arm.com I don't tend to use the M class, but... Could you use WFE instead of WFI? WFE (Wake for Event) will cause the processor to...
Parents
0
Markus Grabner
over 11 years ago
Note: This was originally posted on 9th August 2013 at
http://forums.arm.com
__WFI();
__enable_irq();
__ISB();
__disable_irq();
Should be sufficient.
Looks reasonable. The manual says "Exception entry occurs when there is a pending exception with sufficient priority and either the processor is in Thread mode...", so I guess there is no risk of interrupt "starvation" when enabling interrupts only for a very short period of time (like in the example above).
Kind regards,
Markus
Cancel
Up
0
Down
Cancel
Reply
0
Markus Grabner
over 11 years ago
Note: This was originally posted on 9th August 2013 at
http://forums.arm.com
__WFI();
__enable_irq();
__ISB();
__disable_irq();
Should be sufficient.
Looks reasonable. The manual says "Exception entry occurs when there is a pending exception with sufficient priority and either the processor is in Thread mode...", so I guess there is no risk of interrupt "starvation" when enabling interrupts only for a very short period of time (like in the example above).
Kind regards,
Markus
Cancel
Up
0
Down
Cancel
Children
No data