cancel
Showing results for 
Search instead for 
Did you mean: 

RCC_CSR registers with SBSFU

Istillaga
Associate III

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?

2 REPLIES 2
Jocelyn RICARD
ST Employee

Hello @Istillaga ,

The register will never be equal to 1.

Please check RM0456 Rev 5 page 596.

Best regards

Jocelyn

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;
}
​