Skip to main content
Peter Mather
Associate III
June 14, 2018
Question

Recovering information after software reset

  • June 14, 2018
  • 3 replies
  • 811 views
Posted on June 14, 2018 at 16:39

My program executes a software reset under certain conditions using  'NVIC_SystemReset();'

Before executing the reset I need to set a variable that will still be accessible after the reset so the program can understand the cause and take appropriate action. On a PIC I do this by using a special variable  '_excep_code'.

How can I do the same thing on the  STM32.

Developing on Nucleo-H743, Software Workbench for STM32

    This topic has been closed for replies.

    3 replies

    waclawek.jan
    Super User
    June 14, 2018
    Posted on June 14, 2018 at 17:41

    In linker script, set up a section in RAM, which is not going to be cleared by the startup code.

    This has been discussed here several times, try to search.

    JW

    Jack Peacock_2
    Associate II
    June 14, 2018
    Posted on June 14, 2018 at 20:15

    An alternative to linker sections is to use the backup registers in the RTC.  As long as you have backup domain power it's preserved, plus there's some parasitic write protection during the reset cycle.

      Jack Peacock

    waclawek.jan
    Super User
    June 14, 2018
    Posted on June 14, 2018 at 23:32

    And an alternative to backup registers in RTC there's the backup RAM, if implemented in given model of STM32... ;)

    JW