AnsweredAssumed Answered

STM32F042F6T IWDG doesn't reset (but sets RCC->CSR flag?)

Question asked by Valentin on Nov 21, 2016
Latest reply on Nov 24, 2016 by Valentin
Hi there,

I just came across a problem and was wondering whether I'm doing something wrong here (haven't used IWDG yet).

I'm starting the IWDG and after the timeout it sets the CSR flag as expected - but it doesn't actually reset the core?!
Option bytes are set to SW start, as per default. So it seems the iwdg is running but it just can't reset the core. After a manual reset the leds flash as per check routine and the CSR bit is cleared. But no reset ever happens from the iwdg. Neither in debug mode, nor in free running.

BUT If I uncomment the last line, the flag is never set. So the iwdg gets reset properly. It only can't do the actual reset as it seems. Is there some bit that needs to be set to allow the iwdg to do that? I would expect that to be set during the iwdg init, though.

Any help is much appreciated, thanks!

Here's the code (CubeMX HAL):
void MX_IWDG_Init(void)
  hiwdg.Instance = IWDG;
  hiwdg.Init.Prescaler = IWDG_PRESCALER_4; // 40kHz LSI / 4 = 10KHz
  hiwdg.Init.Window = IWDG_WINDOW_DISABLE;
  hiwdg.Init.Reload = 2000; // 1/10000 * 2000 = 0.2s timeout
  if (HAL_IWDG_Init(&hiwdg) != HAL_OK)

int main(void) {
    /* USER CODE BEGIN 1 */
    /* USER CODE END 1 */
    /* MCU Configuration----------------------------------------------------------*/
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    /* Configure the system clock */
    /* Initialize all configured peripherals */
     * check for IWDG reset occurrence
        // flash x times
        for (int i = 0; i < 20; i++) {
        /* Clear reset flags */
     * Start independent watchdog to auto-restart the mcu in case of a hickup
     * Start listening to CAN
    HAL_CAN_Receive_IT(&hcan, CAN_FilterFIFO0);
    /* USER CODE END 2 */
    /* Infinite loop */
    while (1) {
        /* USER CODE END WHILE */
        /* USER CODE BEGIN 3 */
        // rest is interrupt controlled
        // reload the independent watchdog to prevent system reset
//      HAL_IWDG_Refresh(&hiwdg); // test IWDG reset