cancel
Showing results for 
Search instead for 
Did you mean: 

Identifying System Reset Causes in SBSFU on STM32U575

AoP
Associate

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;
}
1 REPLY 1
PGump.1
Senior III

Hi,

I don't use HAL for such functions. However, you may find that "== 1" is not the correct comparison.

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.