After the STM32 MCU is interrupted, the main function is returned instead of being executed,
As a company project, a function is implemented by the machine when performing a function (this work lasts a long time). If you want to cancel this job, you can reselect it. After thinking for a long time, my colleague reminded me that an external interrupt can be added to the program and the software can be reset during the interruption. The following two sentences are used:
_ Set_FAULTMASK (1); // close all interrupts
NVIC_SystemReset (); // Reset
After the two statements are executed at the end of the interrupt, the system is reset. However, two problems occurred during the running process:
① I found my program dead in the reset function as follows
Static _ INLINE void NVIC_SystemReset (void)
{
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 */
}
Always in while (1.
Solution: I found on the Internet that sometimes the reset chip SP809 cannot be reset by software. After the reset chip is removed, the reset chip is reset.
Analysis: Some netizens said that the reset chip caused the system to fail to lower the reset pin, but another project of my colleagues used the reset chip to reset the software, what is the cause.
② Another problem was found during the debugging process. An external interrupt was triggered but two interrupt service subprograms were entered.
Solution: Disable the External Interrupt after the interruption occurs, and enable the external interrupt at the end of the interrupt service subprogram. This solves the problem of two external interruptions.
Analysis: later on the Internet to find a more authoritative statement: https://my.st.com/public/Faq/Lists/faqlst/DispForm.aspx? ID = 143 & level = 1 & objectid = 141 & type = product & Source =/public/Faq/Tags. aspx? Tags = % 20 interrupt this is a reply from the ST official website, but I also use the clear interrupt mark to the premise according to the above instructions, or two interruptions. The specific cause is to be resolved.