Want (software) reset of CPU (STM32F051) in response to hard fault interrupt but can't compile NVIC_SystemReset() - "implicit declaration..."
I'm exploring STM32F051 using STM32CUBE IDE without use of HAL or lower level support routines (i.e., upon entry at reset vector, manually configure peripheral registers and go - so far so good :)
I wish to cause a reset from within hard fault handler (void HardFault_Handler(void)). I am trying to use NVIC_SystemReset() but this may not be the correct approach.
I've verified that HardFault_Handler(void) is being entered and whatever code I put there executes, however, upon exit (from the handler) the triggering event (a deliberately set up access to an invalid memory-space address) evidently recurs, creating a loop.
NVIC_SystemReset() does not compile (GCC under STM32CubeIDE 1.8.0.) The error reported by the compiler is:
./Src/main.c: In function 'HardFault_Handler':
../Src/main.c:260:2: warning: implicit declaration of function 'NVIC_SystemReset' [-Wimplicit-function-declaration]
Is NVIC_SystemReset() the correct way to cause a reset (cause the CPU to return to initial state and proceed as if reset line were temporarily actuated)? If so, am I missing a .h file?
If there's another mechanism to accomplish a reset in software, I'm happy to use it, but as a beginner I've not yet made it that far in my learning curve.
I found a very similar question asked in the ARM community (URL below) which piqued my interest, however, I'm not far enough along in my learning curve to know how to do this (modify return address at SP+18 to cause the offending instruction to be skipped), so I'd settle for a reset at this point.
Thanks!
