cancel
Showing results for 
Search instead for 
Did you mean: 

Software Reset

rwatt
Associate
Posted on November 11, 2011 at 15:25

I am developing code for the STM32 under the Keil uvision environment. I want to generate a software reset, i.e. if a certain pin is toggled, I want to reset the entire  processor. Please can someone point me to some example code for this. Thanks, Rod

#nvic
6 REPLIES 6
jpeacock2399
Associate II
Posted on November 11, 2011 at 16:21

Software reset is in the M3 core.  Look at the AIRCR register in the SCB, there's a bit to trigger a soft reset.

In the ST library look for the NVIC_SystemReset function in core_cm3.h.  It shows how to use the AIRCR register to genrate a reset.  Here's the code:

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 */

}

rwatt
Associate
Posted on November 11, 2011 at 16:33

Thanks for the update. I am not using the ST libs, I have based my code on the example code provided by the Keil tools. 

Do you have an example which does not use the ST libs?

emalund
Associate III
Posted on November 11, 2011 at 17:07

the version of the St libs provided with keil dates from the days the king of diamonds were still a Jack, but rgey ARE ST generated.

Erik

Posted on November 11, 2011 at 17:45

I am not using the ST libs, I have based my code on the example code provided by the Keil tools.  Do you have an example which does not use the ST libs?

 

 

The use of the library is generally recommended.

*((unsigned long)0x0E000ED0C) = 0x05FA0004;

while(1);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
zabel
Associate III
Posted on December 02, 2011 at 14:23

Hi,

it seemes to me that the NVIC_SystemReset() function does not reset the system fully into power-on state. I am using TIM4 to generate interrupts (upcounting mode), which lead to an spurious interrupt after reset by NVIC_SystemReset(). The problem was, that the initialization routine enabled the interrupt generation first and than later the Timer was started. After reset, as soon as the interrupt generation was enabled the interrupt fired before the timer was again started.

Is there anything one can do to get a full power up reset without having to de-initialize every used component seperately?

-- Dirk

emalund
Associate III
Posted on December 02, 2011 at 16:29

I guess you will get in trouble generating a reset inside an ISR. a solution would be to run di() early and then enable the interrupts at main()

Erik