STM32复位2

参考:https://blog.csdn.net/weixin_39674445/article/details/88924682

最近产品要加软复位的功能,在网上搜集了一下,有以下结果:

void Sys_Soft_Reset(void)
{  
    SCB->AIRCR =0X05FA0000|(u32)0x04;      

这样的一个函数就可以实现软复位的效果,具体这样做的依据是什么,搜集了一些知识点,可能和这个函数沾边,也可能不沾边,但是都是软件复位有关的一些知识点,因此粘出来,分享一下。

 

通过搜集CM3权威指南,找到了一些知识点:

Self-Reset Control

//Cortex-M3提供两种自复位控制功能。 第一个是NVIC应用中断和复位控制寄存器(位[0])中的VECTRESET控制位:

The Cortex-M3 provides two self-reset control features. The fi rst one is the VECTRESET 
control bit in the NVIC Application Interrupt and Reset Control register (bit [0]):

 

//写入该位将复位Cortex-M3处理器,不包括调试逻辑。 这不会重置Cortex-M3处理器之外的任何电路。 例如,如果SoC包含UART,写入该位不会复位UART或Cortex-M3外部的任何外围设备

 

Writing to this bit will reset the Cortex-M3 processor, excluding the debug logic. This does not reset any circuit outside the Cortex-M3 processor. For example, if the SoC contains a UART, writing to this bit does not reset the UART or any peripherals outside the Cortex-M3

//第二个复位功能是同一NVIC寄存器中的SYSRESETREQ位。 它允许Cortex-M3处理器向系统的复位发生器发出复位请求信号。 由于系统复位发生器不是Cortex-M3设计的一部分,因此复位功能的实现取决于芯片设计。 因此,有必要仔细检查芯片的规格,因为某些芯片可能不存在此功能!

The second reset feature is the SYSRESETREQ bit in the same NVIC register. It allows the 
Cortex-M3 processor to assert a reset request signal to the system’s reset generator. Since 
the system reset generator is not part of Cortex-M3 design, the implementation of this reset 
feature depends on the chip design. Therefore, it is necessary to carefully check the chip’s 
specifi cation because this feature might not exist in some chips!

Here’s an example code using the SYSRESTREQ:
 LDR R0,0xE000ED0C ; NVIC AIRCR address
 LDR R1,0x05FA0004 ; Set SYSRESETREQ bit (05FA is a write 
; access key)
 STR R1,[R0]
deadloop
 B deadloop ; a deadloop is used to ensure no other 
; instructions
 ; follow the reset is executed

//大多数情况下,当SYSRESETREQ位置1时,Cortex M3处理器(SYSRESETn)的系统复位信号将由复位发生器置位。 根据芯片设计,它可能会或可能不会复位芯片的其他部分,例如外围设备。 通常这不应该重置Cortex-M3的调试逻辑。

In most cases, when the SYSRESETREQ bit is set, the system reset signal of the CortexM3 processor (SYSRESETn) will be asserted by the reset generator. Depending on the chipdesign, it might or might not reset the other parts of the chip, such as peripherals. Normally this should not reset the debug logic of the Cortex-M3.

//请注意,从复位发生器断言SYSRESETREQ到实际复位的延迟也是一个问题。 由于复位发生器的延迟,您可能会在设置复位请求后发现处理器仍然接受中断。 如果要在运行此代码之前停止内核接受中断,可以使用MSR指令设置FAULTMASK。

Note that the delay from assertion of SYSRESETREQ to actual reset from the reset generator can also be an issue. Due to delay in the reset generator, you might find the processor still accepting interrupts after the reset request is set. If you want to stop the core from accepting interrupts before running this code, you can set the FAULTMASK using the MSR instruction.

具有参考意义的链接如下:

http://www.openedv.com/forum.php?mod=viewthread&tid=82603&highlight=%CF%B5%CD%B3%C8%ED%B8%B4%CE%BB

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值