How to handle HardFault?
There is a function called HardFault_Handler in the STM32 MCUs (full code below). This function I usually work with when debugging but am unsure how to use this for handling error. What is the correct protocol to handle errors in this function? If a fault has happened ideally I would like to clear the MCU ram and reset the MCU. However what if the handler code causes more faults. Is there a standard protocol for handling faults (not just HardFaults)?
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}