2024-10-03 12:36 AM
Hello,
I am using SBSFU on the STM32U5 microcontroller, and I have implemented a function to determine the cause of the system reset by reading the RCC register flags. However, every time I enter the function, it always returns an 'unknown reset' value.
I have used the following function:
unsigned char SYS_Reset_Cause(void)
{
unsigned int reset_cause;
reset_cause=UKW_RESET;
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) == 1)
{
reset_cause = SFT_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) == 1)
{
reset_cause = PWO_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) == 1)
{
reset_cause = WDG_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) == 1)
{
reset_cause = HRD_RESET;
}
else if(__HAL_PWR_GET_FLAG(PWR_FLAG_SBF) != 0)
{
reset_cause = ALR_RESET;
}
__HAL_RCC_CLEAR_RESET_FLAGS();
return reset_cause;
}
2024-10-03 12:53 AM
Hi,
I don't use HAL for such functions. However, you may find that "== 1" is not the correct comparison.
Kind regards
Pedro