最近产品要加软复位的功能,在网上搜集了一下,有以下结果:
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