本文介绍了NVIC_SystemReset()while循环(STM32F302VB)卡在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个STM32F302VB,我需要执行软件复位。在我所有的previous项目(STM32F427和STM32F030C8),我一直使用的NVIC_SystemReset()函数成功。但由于某些原因,它不会以这种芯片的工作。
实施是在CMSIS core_cm4.h和如下:

I'm currently developing on a STM32F302VB and I need to perform a software reset. On all my previous projects (with STM32F427 and STM32F030C8), I've always used the NVIC_SystemReset() function successfully. But for some reason it won't work with this chip.The implementation is in CMSIS core_cm4.h and is as follows:

__STATIC_INLINE void NVIC_SystemReset(void)
{
  __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */
  SCB->AIRCR  = ((0x5FA << SCB_AIRCR_VECTKEY_Pos)      |
             (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
             SCB_AIRCR_SYSRESETREQ_Msk);                   /* Keep priority group unchanged */
  __DSB();                                                     /* Ensure completion of memory access */
  while(1);                                                    /* wait until reset */
}

该函数被调用,所有的指令都执行,但卡住了while循环,并重置从未发生过。然后,我有通过JTAG重置把它弄出来的状态。

The function is called and all instructions are executed, but it gets stuck in the while loop, and reset never happens. I then have to reset it via JTAG to get it out of that state.

我查了编程手册和实现似乎罚款(并不奇怪,因为它完美对F4和F0)。

I checked the programming manual and the implementation seems fine (not surprising since it works perfectly on F4 and F0).

我真的不知道这个问题可能是什么,是否有人有一个想法,这是怎么回事?

I really don't know what the problem might be, does someone have an idea what's going on?

编辑:该功能仍然没有工作,但作为一种解决方法,功能卡后,我拉下NRST引脚再起来。它的丑陋,但它的作品现在。我宁愿做这一切在软件虽然。

The function is still not working but as a workaround, after the function gets stuck, I pull down the nRST pin and then up. It's ugly, but it works for now. I would rather do it all in software though.

推荐答案

托尼·K的就在他的评论,NRST引脚确实被拉高外,因为路由错误。

Tony K was right in his comment, the nRST pin was indeed being pulled high externally, because of a routing mistake.

出乎我的想法,NRST引脚是考虑到即使在软件复位:参考手册说:[重置]来源行事NRST引脚上,并在延迟阶段始终保持在较低水平,所以我应该知道!

And contrary to what I thought, the nRST pin is taken into account even in a software reset: the reference manual says: "[Reset] sources act on the NRST pin and it is always kept low during the delay phase", so I should have known!

删除上拉的伎俩,现在可以按预期的NVIC_SystemReset()函数!

Removing the pull-up did the trick, the NVIC_SystemReset() function now works as expected!

非常感谢你!

这篇关于NVIC_SystemReset()while循环(STM32F302VB)卡在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 15:11