NVIC_SystemReset() stuck in while loop (STM32F302VB)

十年热恋 提交于 2020-01-06 19:24:35

问题


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 */
}

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.

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?

Edit: 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.


回答1:


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

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!

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

Thank you very much!



来源:https://stackoverflow.com/questions/33875788/nvic-systemreset-stuck-in-while-loop-stm32f302vb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!