Get reset reason Timing:
After RTD power module is initialized by function Power_Ip_Init, I read reset reason by RTD function Power_Ip_GetResetRawValue or Power_Ip_GetResetReason.
First times
After cold power on, ResetRawValue is 8000, ResetReason is 0(MCU_POWER_ON_RESET).
Mcu could be working well, and then perform a functional reset by RTD function BSP_PwrSoftwareReset, Reset type is configurated to MCU_FUNC_RESET.
Second times
After MCU is reset due to functional reset,ResetRawValue is 800, ResetReason is 26(MCU_SW_FUNC_RESET).
Mcu keeps working about 1s, and then is reset due to unknown reason.
Third and more times
After MCU is reset due to unknown reason,ResetRawValue is 200, ResetReason is 24(MCU_HSE_SWT_RST_RESET).
Mcu keeps working about 1s, and then is reset due to unknown reason.
Addition:
if I comment process for clearing MC_RGM.DES in RTD function Power_Ip_MC_RGM_GetResetRawValue and Power_Ip_MC_RGM_GetResetReason, MC_RGM.DES is keep F_POR=1,
MCU will not be reset due to unknown reason after the functional reset.
Refence source:
Power_Ip_ResetType reset_reason;
Power_Ip_RawResetType reset_raw_reason;
int main()
{
Power_Ip_Init(&Power_Ip_HwIPsConfigPB);
Wkpu_Ip_Init(0,&Wkpu_Ip_Config_PB);
reset_raw_value = Power_Ip_GetResetRawValue();
reset_reason = Power_Ip_GetResetReason();
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
// unknown reset occurred at this timing
while(Hse_Ip_GetHseStatus(MU0) & HSE_STATUS_INIT_OK)
{
;
}
while(1)
{
// main loop
}
}
// called in main loop
void UserPerformFunctionalReset(void)
{
Power_Ip_PerformReset(&Power_Ip_HwIPsConfigPB);
}