After the STM32 MCU is interrupted, the main function is returned instead of being executed,

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.