Skip to main content
Scott Dev
Senior
Sep 25, 2018 2:48 PM UTC
Question

Resetting STM32L4

Hi

What is the best way of resetting the STM32L4 processor using registers?

Thanks

Scott

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    Sep 25, 2018 2:51 PM UTC

    Just call NVIC_SystemReset(), it is in the library

    /**

     \brief  System Reset

     \details Initiates a system reset request to reset the MCU.

     */

    __STATIC_INLINE void NVIC_SystemReset(void)

    {

     __DSB();                                                         /* Ensure all outstanding memory accesses included

                                                                          buffered write are completed before reset */

     SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos)   |

                              (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |

                               SCB_AIRCR_SYSRESETREQ_Msk   );        /* Keep priority group unchanged */

     __DSB();                                                         /* Ensure completion of memory access */

     for(;;)                                                          /* wait until reset */

     {

       __NOP();

     }

    }

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Scott Dev
    Scott DevAuthor
    Senior
    Sep 25, 2018 3:10 PM UTC

    Thanks Clive