cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411: HAL_WWDG_Start_IT causes immediate interrupt

danieldaniel92
Associate
Posted on July 13, 2016 at 18:40

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. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialise all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_I2C1_Init();
MX_IWDG_Init();
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
MX_USB_OTG_FS_USB_Init();
MX_WWDG_Init();
HAL_WWDG_Refresh(&hwwdg, 0x7F);
#ifdef WWDG_INTERRUPTS
HAL_WWDG_Start_IT(&hwwdg);
#else
HAL_WWDG_Start(&hwwdg);
#endif

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;
HAL_WWDG_Init(&hwwdg);
}
void HAL_WWDG_MspInit(WWDG_HandleTypeDef* hwwdg)
{
if(hwwdg->Instance==WWDG)
{
/* USER CODE BEGIN WWDG_MspInit 0 */
/* USER CODE END WWDG_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_WWDG_CLK_ENABLE();
/* Peripheral interrupt init */
#ifdef WWDG_INTERRUPTS
HAL_NVIC_SetPriority(WWDG_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(WWDG_IRQn);
#endif
/* 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? #wwdg #watchdog #hal-libraries
1 REPLY 1
Walid FTITI_O
Senior II
Posted on July 15, 2016 at 16:57

Hi Jin,

The WWDG driver has been reworked in the last release. this duntion has been totally removed. Try to download the last STM32CubeF4 release from this Link

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef4.html

-Hannibal-