Skip to main content
HoangDuong
Associate II
December 29, 2021
Solved

how to issue one time software reset STM32F0xx after power up.

I need issue software reset after 1s when power up stm32f0xx, like press hardware reset button but i need in software. plz help me implement only one time after amount 1 second when power up stm32.

This topic has been closed for replies.
TDK
TDKBest answer
December 29, 2021

You can check if the last reset was a software reset by reading RCC_CSR flags.

You can check the approximate time from reset by looking at HAL_GetTick() >= 1000.

You can perform a software reset by calling HAL_NVIC_SystemReset.

Put those three together.

"If you feel a post has answered your question, please click ""Accept as Solution""."

7 replies

MM..1
Super User
December 29, 2021

In reset flag you can check power on reset and do for example iwdg

TDK
TDKBest answer
December 29, 2021

You can check if the last reset was a software reset by reading RCC_CSR flags.

You can check the approximate time from reset by looking at HAL_GetTick() >= 1000.

You can perform a software reset by calling HAL_NVIC_SystemReset.

Put those three together.

"If you feel a post has answered your question, please click ""Accept as Solution""."
HoangDuong
Associate II
December 30, 2021

Thanks for answer!

it not what i want. i can use iwdg or NVIC_SystemReset in normal mode, but not in this situation.

after power up MCU, if i put NVIC_SystemReset in code or timer, next time it will reset, but i only want it reset one time. And, after reset it will working normal and do not executed reset command any more. (only executed soft reset one time when power up)

TDK
December 30, 2021
That is why you read the RCC CSR register to determine if last reset was soft reset and if so, don’t reset again. That is exactly what you want based on your description.
"If you feel a post has answered your question, please click ""Accept as Solution""."
HoangDuong
Associate II
December 30, 2021

@TDK​ 

Thanks so much, i dont know stm32 have some reset flag to monitor reset status of MCU. This is exactly what i need, just monitor SFTRSTF bit in RCC_CSR will know hardware or software reset

Piranha
Principal III
December 30, 2021

Taka a note that the software reset bit (SFTRSTF) will be set also on NRST pin reset and therefore on POR/BOR resets also. Most likely you have to check POR/BOR or NRST reset flags for your goal.

HoangDuong
Associate II
December 31, 2021

Thanks for your suggestion Piranha.