2011-11-11 06:25 AM
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
#nvic2011-11-11 07:21 AM
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 */}
2011-11-11 07:33 AM
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?2011-11-11 08:07 AM
2011-11-11 08:45 AM
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);
2011-12-02 05:23 AM
2011-12-02 07:29 AM
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