2024-10-03 10:12 AM - edited 2024-10-03 10:31 AM
Hello,
I am working with SBSFU on a STM32U575 microcontroller and have written a function to check the cause of the system reset by reading the flags from the RCC registers using __HAL_RCC_GET_FLAG. However, the issue is that none of the RCC register flags are ever equal to 1, so I am unable to determine the reset cause properly. What exactly needs to be modified to be able to read those registers?
2024-10-03 10:35 AM
Hello @Istillaga ,
The register will never be equal to 1.
Please check RM0456 Rev 5 page 596.
Best regards
Jocelyn
2024-10-03 10:47 AM - edited 2024-10-03 11:14 AM
Hello @Jocelyn RICARD ,
I know that the register will not going to be one but using the following function that I’ve implemented to read the reset flags from both PWR and RCC registers to determine the cause of a system reset. However, every time I run it, it keeps returning unknown reset. Any idea why this might be happening?
unsigned char Get_Reset_Cause(void)
{
unsigned char cause = UKN_RESET; // Default if no cause is found
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != 0)
{
cause = SOFT_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) != 0)
{
cause = POWER_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != 0)
{
cause = WATCHDOG_RESET;
}
else if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != 0)
{
cause = HARD_RESET;
}
else if (__HAL_PWR_GET_FLAG(PWR_FLAG_SBF) != 0)
{
cause = STANDBY_RESET;
}
// Clear reset flags after reading
__HAL_RCC_CLEAR_RESET_FLAGS();
return cause;
}
2024-10-15 12:53 AM
Hello @Jocelyn RICARD,
Just following up on my previous question about the function I implemented to read the reset flags from the PWR and RCC registers. It keeps returning "unknown reset" every time I run it. Any idea why this might be happening?