Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use hardfault exception library ?

Hi,

I'm using nrf52832 and sdk14.2 and need to handle hardfaults in my code. From what I've found on the forums and infocenter, I need to modify the "void HardFault_process(HardFault_stack_t * p_stack);" function in hardfault_implementation.c file. By default it resets the chip. So to test this function I enabled the hardfault_handler_enabled macro in sdk_config.h and generated a hard fault using following code.

int* ff = 0x80000000;
*ff = 3;

Now i get the error, but the system doesn't reset as it should acc. to the default implementation.

To further debug, i put a breakpoint inside "void HardFault_c_handler(uint32_t * p_stack_address)" function in hardfault_implementation.c file, but this function never gets called. So the hardfault library is not working properly. Is there anything that I'm missing here ?

Also, I tried to use following functions in my main.c, to generate hardfaults for testing, but i get "undefined reference" errors while compiling ?

hardfault_genhf_invalid_fp

hardfault_genhf_undefined_instr

hardfault_genhf_ldm_align

So, what am i doing wrong here ?

Related