2015-07-17 07:18 AM
Hi,
I am having problems to run the WWDG in a STM32F405.I am using the HAL Drivers from Cube MX.The process is the following:{__HAL_RCC_WWDG_CLK_ENABLE();MX_WWDG_Init();HAL_WWDG_Start(&hwwdg);HAL_WWDG_Refresh(&hwwdg,127);}Where:void MX_WWDG_Init(void){ hwwdg.Instance = WWDG; hwwdg.Init.Prescaler = WWDG_PRESCALER_1; hwwdg.Init.Window = 80; hwwdg.Init.Counter = 127; HAL_WWDG_Init(&hwwdg);}The problem is that the program never reaches the refresh function. It resets the micro in the line showed below:HAL_StatusTypeDef HAL_WWDG_Start(WWDG_HandleTypeDef *hwwdg){ /* Process Locked */ __HAL_LOCK(hwwdg); /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_BUSY; /* Enable the peripheral */ __HAL_WWDG_ENABLE(hwwdg); // THE MICRO RESETS AFTER CALLING THAT FUNCTION! /* Change WWDG peripheral state */ hwwdg->State = HAL_WWDG_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hwwdg); /* Return function status */ return HAL_OK;}Any clues? #stm32f1-wwdg-iwdg2015-07-17 09:46 AM
Hi,
I suggest you to start from one example of WWDG from the STM32cubeF4 package-Syrine-2015-07-17 10:19 AM
Before you enable the WWDG you have to make sure the timer is inside the window. Enabling WWDG if the counter is outside the window forces a reset.
I poll WWDG->CR register until it is well above the min threshold, about half way in the window, before turning it on. I don't use the HAL so no idea if there's any support for making sure the WWDG is in a good place before enabling. Jack Peacock2015-07-20 12:14 PM
The Cube example is presented below. The code is basicly the same as mine. Still not working!
/*##-2- Configure the WWDG peripheral ######################################*/ /* WWDG clock counter = (PCLK1 (42MHz)/4096)/8) = 1281 Hz (~780 us) WWDG Window value = 80 means that the WWDG counter should be refreshed only when the counter is below 80 (and greater than 64) otherwise a reset will be generated. WWDG Counter value = 127, WWDG timeout = ~780 us * 64 = 49.9 ms */ WwdgHandle.Instance = WWDG; WwdgHandle.Init.Prescaler = WWDG_PRESCALER_8; WwdgHandle.Init.Window = 80; WwdgHandle.Init.Counter = 127; if(HAL_WWDG_Init(&WwdgHandle) != HAL_OK) { /* Initialization Error */ Error_Handler(); } /*##-5- Start the WWDG #####################################################*/ if(HAL_WWDG_Start(&WwdgHandle) != HAL_OK) { Error_Handler(); } /* Infinite loop */ while (1) { /* Toggle LED2 */ BSP_LED_Toggle(LED2); /* Insert 40 ms delay */ HAL_Delay(40); /* Refresh WWDG: update counter value to 127, the refresh window is: ~780 * (127-80) = 36.6ms < refresh window < ~780 * 64 = 49.9ms */ if(HAL_WWDG_Refresh(&WwdgHandle, 127) != HAL_OK) { Error_Handler(); } }2015-11-20 02:08 AM
2016-08-31 07:26 AM
Hi,
Did you find any solution about this issue with using HAL libs ? Best Regards