AnsweredAssumed Answered

STM32F411: HAL_WWDG_Start_IT causes immediate interrupt

Question asked by Jin on Jul 13, 2016
Latest reply on Jul 15, 2016 by FTITI.Walid
I have a project using the HAL libraries on STM32F411, init code all generated by CubeMX.

If I use the HAL libraries to setup the WWDG in normal mode (no interrupt) it works perfectly. If I use the same parameters but enable interrupts, as soon as it call HAL_WWDG_Start_IT() the interrupt is fired immediately.

In main.c it goes something like this:

    /* Reset of all peripherals, Initialises the Flash interface and the Systick. */
    /* Configure the system clock */
    /* Initialise all configured peripherals */
    MX_TIM1_Init(); // W Axis Motor
    MX_TIM2_Init(); // R Encoder
    MX_TIM3_Init(); // W Encoder
    MX_TIM4_Init(); // Z Axis Motor
    MX_TIM5_Init(); // Z Encoder
    MX_TIM10_Init(); // R Axis Motor
    MX_TIM11_Init(); // G AXIS PWM
    MX_USART2_UART_Init(); // Camera UART
    MX_USART6_UART_Init(); // Pi/Control UART
    HAL_WWDG_Refresh(&hwwdg, 0x7F);

In wwdg.c this is the code:

/* WWDG init function */
void MX_WWDG_Init(void)
  hwwdg.Instance = WWDG;
  hwwdg.Init.Prescaler = WWDG_PRESCALER_8;
  hwwdg.Init.Window = 0x7F;
  hwwdg.Init.Counter = 0x7F;
void HAL_WWDG_MspInit(WWDG_HandleTypeDef* hwwdg)
  /* USER CODE BEGIN WWDG_MspInit 0 */
  /* USER CODE END WWDG_MspInit 0 */
    /* Peripheral clock enable */
    /* Peripheral interrupt init */
   HAL_NVIC_SetPriority(WWDG_IRQn, 0, 0);
  /* USER CODE BEGIN WWDG_MspInit 1 */
  /* USER CODE END WWDG_MspInit 1 */

If I #undef WWDG_INTERRUPTS, the code works, if I #define WWDG_INTERRUPTS it immediately interrupts as described.

What am I missing here?