Hello,
I'm working with nRF5 SDK v16.0.0.
The documentation on Hardfault handler implementation clearly suggests to define DEBUG_NRF in order to get an automatic breakpoint on HF, before the call to HardFault_process
What I see in the code it is this instead:
#if defined(DEBUG)
NRF_BREAKPOINT_COND;
#endif // defined (DEBUG)
#endif // __CORTEX_M == 0x04
HardFault_process((HardFault_stack_t *)p_stack_address);
}
What's the difference between DEBUG and DEBUG_NRF? I don't see any explicit relation between the two, and as such I think there could be a mistake on the documentation.
DEBUG is used in the app_error libraries as well.
Moreover, the signature header of HardFault_process states:
/**
* @brief Function for processing HardFault exceptions.
*
* An application that needs to process HardFault exceptions should provide an implementation of this function.
* It will be called from the HardFault handler.
* If no implementation is provided, the library uses a default one, which just restarts the MCU.
*
* @note If the DEBUG_NRF macro is defined, the software breakpoint is set just before the call
* to this function.
*
* @param p_stack Pointer to the stack bottom.
* This pointer might be NULL if the HardFault was called when the main stack was
* the active stack and a stack overrun is detected.
* In such a situation, the stack pointer is reinitialized to the default position,
* and the stack content is lost.
*/
void HardFault_process(HardFault_stack_t * p_stack);
Can you point me to the code which is handling the case of main stack + stack overrun, so that p_stack is set to NULL? I did not find anything as such.
Moving back to macro definitions, it would be great to have a document where the usage DEBUG_NRF, DEBUG and other switches used in the code to enable debug behaviour is described.
If such a document already exists, please let me know!
Thanks a lot,
Kind Regards,
D