Skip to main content
dmatheis
Associate III
July 20, 2009
Question

Call a function before reseting by NRST

  • July 20, 2009
  • 4 replies
  • 1021 views
Posted on July 20, 2009 at 12:38

Call a function before reseting by NRST

    This topic has been closed for replies.

    4 replies

    dmatheis
    dmatheisAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    Hello,

    is it possible to call a function before the NRST-Pin resets the hole system (e.g. to save some data in an external eeprom)? Is there any IRQ-Handler which could be called when pressing the switch connected to my NRST-Pin?

    Thank you :D

    swhite
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    A reset is a hardware condition that can't be trapped like a normal exception.

    That said you can determine the cause of a reset *after* it has happened. See the ST Library function RCC_GetFlagStatus(). I do this in a current project to display/log the last reset cause along with additional information. Makes a great firmware/hardware debugging feature :)

    Edit: You can (and I do) get indication of a power failure and do stuff *before* you reset.

    [ This message was edited by: swhite on 20-07-2009 16:09 ]

    dmatheis
    dmatheisAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    Hi M3allem,

    thanks for your replay, but I'm searching for a solution to get the beheavior/functionality of the EXTI also on the NRST pin. :-]

    m3allem
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    Hi dmatheis;

    You can use EXTI interrupt instead of NRST-Pin to reset the microcontroller.

    How?

    So you can connect a button in any EXTI. In the EXTI handler you can save your data and after that call NVIC_GenerateSystemReset() (software reset).

    B.R.

    M3allem