cancel
Showing results for 
Search instead for 
Did you mean: 

Call a function before reseting by NRST

dmatheis
Associate II
Posted on July 20, 2009 at 12:38

Call a function before reseting by NRST

4 REPLIES 4
dmatheis
Associate II
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

sofiene
Associate III
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

dmatheis
Associate II
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. :-]

swhite
Associate III
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 ]