# How to debug a HardFault on an ARM Cortex-M MCU | Interrupt

**URL:** <https://community.memfault.com/t/how-to-debug-a-hardfault-on-an-arm-cortex-m-mcu-interrupt/607>\
**Category:** Blog\
**Created:** [November 1, 2022, 1:16am UTC](https://community.memfault.com/t/how-to-debug-a-hardfault-on-an-arm-cortex-m-mcu-interrupt/607 "2022-11-01T01:16:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.memfault.com/discobot/32/1_2.png) [@discobot](https://community.memfault.com/u/discobot)\
**Post date:** [November 1, 2022, 1:16am UTC](https://community.memfault.com/t/how-to-debug-a-hardfault-on-an-arm-cortex-m-mcu-interrupt/607/1 "2022-11-01T01:16:21Z")

</div>

Faults happen on embedded devices all the time for a variety of reasons – ranging from something as simple as a NULL pointer dereference to something more unexpected like running a faulty code path only when in a zero-g environment on the Tower of Terror in Disneyland. It’s important for any embedded engineer to understand how to debug and resolve this class of issue quickly.

* * *
This is a companion discussion topic for the original entry at [https://interrupt.memfault.com/blog/cortex-m-hardfault-debug](https://interrupt.memfault.com/blog/cortex-m-hardfault-debug)

---

<div class="post-metadata">

**Author:** ![ashaan\_111](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@ashaan\_111](https://community.memfault.com/u/ashaan_111)\
**Post date:** [January 8, 2024, 2:00pm UTC](https://community.memfault.com/t/how-to-debug-a-hardfault-on-an-arm-cortex-m-mcu-interrupt/607/2 "2024-01-08T14:00:47Z")

</div>

hey,  
im not sure if i missed something when I saw this gdb command in this blog where you find out which stack pointer was being used prior to exception by looking at the 2nd bit of lr register. how can you say if it is psp or msp by looking at lr register? doesn’t it just hold the return address?

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.memfault.com/discobot/32/1_2.png) [@discobot](https://community.memfault.com/u/discobot)\
**Post date:** [January 8, 2024, 2:00pm UTC](https://community.memfault.com/t/how-to-debug-a-hardfault-on-an-arm-cortex-m-mcu-interrupt/607/3 "2024-01-08T14:00:47Z")

</div>


