Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

NVIC_SystemReset () not working for STM32F4

Writer Olivia Zamora

I am working on STM32F4 board. My IDE is IAR Embedded Work bench. I am trying to do a software reset from code. For that i used API ' NVIC_SystemReset(); ' defined in core_cm4.h header. But the system reset is not happening.

I tried the same thing in STM32F3, same IDE . I used the function NVIC_SystemReset(); from core_sc300.h header. Using that software reset is happening. I found the definition of functions in both file are same and both controllers are Cortex M4 only.What is the problem with STM32F4 board.? Can any one help me in solving this or can any one suggest an alternative way for system reset in STM32F4.

Please help. Thanks in advance

0

3 Answers

In the HAL You can use

HAL_NVIC_SystemReset();
0

You can use a watch-dog instead:

  • Call wdg_activate(n) in order to initiate system-reset within n milliseconds
  • Call wdg_reactivate() in order to reload the counter back to n milliseconds

void wdg_activate(unsigned short num_of_ms)
{ uint8_t prescale_reg; uint8_t prescale_val; if (num_of_ms < 1) { num_of_ms = 1; prescale_reg = IWDG_Prescaler_32; prescale_val = 1; } else if (num_of_ms <= 4096) { prescale_reg = IWDG_Prescaler_32; prescale_val = 1; } else if (num_of_ms <= 8192) { prescale_reg = IWDG_Prescaler_64; prescale_val = 2; } else if (num_of_ms <= 16384) { prescale_reg = IWDG_Prescaler_128; prescale_val = 4; } else if (num_of_ms <= 32768) { prescale_reg = IWDG_Prescaler_256; prescale_val = 8; } else { num_of_ms = 32768; prescale_reg = IWDG_Prescaler_256; prescale_val = 8; } IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); while (IWDG_GetFlagStatus(IWDG_FLAG_PVU)); IWDG_SetPrescaler(prescale_reg); while (IWDG_GetFlagStatus(IWDG_FLAG_RVU)); IWDG_SetReload(num_of_ms/prescale_val-1); IWDG_Enable();
}

void wdg_reactivate()
{ IWDG_ReloadCounter();
}
1

There have been several iterations of NVIC_SystemReset(). Please post the code for the version you are using. The current [working STM32F4] version that I am using is as follows:

/** \brief System Reset The function initiates a system reset request to reset the MCU. */
__STATIC_INLINE void NVIC_SystemReset(void)
{ __DSB(); /* Ensure all outstanding memory accesses included buffered write are completed before reset */ 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 */
}

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy