Cortex-M Exception Handling (Part 2)
The first part of this article described the conditions for an exception request to be accepted by a Cortex-M processor, mainly concerning the relationship of its priority with respect to the current execution priority. This...
Summary
This follow-up article continues the deep dive into Cortex-M exception mechanics, focusing on stacking/unstacking, entry/exit timing, tail-chaining, and priority masking. It also covers how these behaviors interact with RTOS context switching (PendSV/SVC), lazy FPU stacking, and practical fault-diagnosis techniques the reader can apply to real firmware.
Key Takeaways
- Explain how Cortex-M stacks and unstacks registers on exception entry/exit and how to interpret the stacked frame for debugging.
- Describe tail-chaining and lazy FPU stacking and quantify their impact on interrupt latency.
- Use PRIMASK, BASEPRI, FAULTMASK, and NVIC priority grouping correctly to control preemption and protect critical sections.
- Design RTOS-friendly context switches using PendSV/SVC and avoid common pitfalls with nested interrupts and priority inversion.
- Apply practical methods to diagnose HardFault/BusFault/UsageFault causes by analyzing stack frames and SCB registers.
Who Should Read This
Embedded firmware engineers working with Cortex-M microcontrollers or RTOS-based systems who need a deeper, practical understanding of exception behavior, interrupt latency, and fault debugging.
Still RelevantAdvanced
Related Documents
- Consistent Overhead Byte Stuffing TimelessIntermediate
- PID Without a PhD TimelessIntermediate
- Introduction to Embedded Systems - A Cyber-Physical Systems Approach Still RelevantIntermediate
- Can an RTOS be really real-time? TimelessAdvanced
- Memory Mapped I/O in C TimelessIntermediate








