STM32如何获得上次复位状态 [英] STM32 how to get last reset status

查看:681
本文介绍了STM32如何获得上次复位状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用STM32F427,我想获取上次重置的原因.有RCC时钟控制和状态寄存器RCC_CSR带有许多重置标志,但是我无法获得任何有意义的值.

I'm working with STM32F427 and I'd like to get cause of last reset. There is RCC clock control & status register RCC_CSR with many reset flags, but I'm not able to get any meaningful value.

通过读取该寄存器的值,我只会得到0x03,这意味着LSI准备就绪且LSI ON,但是如果尝试上电,软件复位,低压等,则未设置有关复位的标志.收到如下所示的重置标志,但所有标志仍为0.

By reading the value of that register, I get only 0x03, which means LSI ready and LSI ON, but no flags about reset are set if I try power on, software reset, low voltage etc. I found snippet of code for getting reset flags like below, but all the flags are still 0.

if (RCC_GetFlagStatus(RCC_FLAG_SFTRST)) ...

您对如何获得更好的结果有任何建议吗?在读取这些重置标志之前是否需要一些配置?

Do you have any suggestions how to get better results? Is there some needed configuration before reading these reset flags?

谢谢

推荐答案

启动后应尽快读取RCC_CSR,然后再初始化其他任何外围设备.首先初始化系统时钟是安全的(如果使用ST的库,则可以在SystemInit()中完成).

Read RCC_CSR as soon as possible after startup, before initializing any other peripheral. It is safe to initialize your system clocks first (which is done in SystemInit() if you use ST's libraries).

这篇关于STM32如何获得上次复位状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆