This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

Hardfault - nrf51

I'm having a weird hardfault and, I can't make sense of it. Here's what I do know: nrf sdk 9.0.0; nrf51422 on a dk; I have RTC1, SPI0, and TWI1 enabled (also a uart for logging); I have the S130 enabled; Priorities seem to be good;

Upon start, I initialize my peripherals and my ble service. Everything works great until I receive a connection request from an android app. Fairly shortly, my code hardfaults.

As far as hardfault debugging, here are the details: My Link Register = 0xFFFFFFF9; I believe this tells me two things, 1) That it hard faulted on a return to thread mode 2) bit 4 is set so, it is using the Main Stack Pointer (MSP). My main stack pointer points at 0x20007ce8 (expected, it's in ram). When, i add 0x18, I get 0x20007d00. As far as I know, this should be the location where the pc was stored at the time of the hardfault. The value of my pc is 2. That's what's confusing for me. 0 is the address for the initial stack pointer and 4 is the address for code to begin on reset. 2 is in the middle.

Due to the all nighter, I am most likely missing something. Any help would be greatly appreciated.

Thank you.

  • That analysis seems correct. It's possible that you did jump to 0x00000002 and tried executing code which then caused a hardfault. What's at SP+0x14? That's the link register at the time of the exception, ie the return address for the last function called before whatever caused the hardfault. Perhaps that might give you a clue where you came from and how you got there.

  • Thank you for the tip and the acknowledgement that my logic is sound. My link register from the stack was pointing to a instruction in disassembly for outputting characters via UART. I'm going to do some more digging, I'm sure I'm doing something illogical somewhere. I'm noticing that it's failing directly after a ble connection message receive event.

Related