2012-11-12 11:58 AM
The following is my watchdog code. The watchdog is triggering and I am constantly find myself in the startup routine. Why? Here is my watchdog related code:
//After Periph Clock set and before GPIO and NVIC setup //RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE); //WWDG_SetPrescaler(WWDG_Prescaler_1); //WWDG_SetWindowValue(0x7F); //WWDG_Enable(0x7F); //in main's while loop //1 tick = 10ms if (timeDiff >= 10){ //WWDG_SetCounter(0x7F); for (loop = 0; loop < TIMERSIZE; loop++){ if (tmrOn[loop] > 0){ on = 1; } else{ on = 0; } if (tmrTicks[loop] > 65530u){ tmrTicks[loop] = 65530u; } tmrTicks[loop] = on * (tmrTicks[loop] + 1); } lastTime = time; timeDiff = 0; }2012-11-12 12:21 PM
Wouldn't you want to pick a Window Value that you have some chance of meeting? ie greater than 64, but LOWER than your starting point. If the window shuts as soon as it starts you're never going to be able to kick it.
2012-11-13 06:02 AM
So WWDG_SetWindowValue(0x7F) function sets the value at which the watchdog downcounter will activate and reset micro? Which is why it should be set greater than 0x40? Can you get below 0x40 and is that a different type of watchdog timer reset? Why did you suggest 0x64?
2012-11-13 08:53 AM
Have you looked at the example, or considered the IWDG?
STM32F0xx_StdPeriph_Lib_V1.0.0\Project\STM32F0xx_StdPeriph_Examples\WWDG\WWDG_Example\main.c/* WWDG configuration */
/* Enable WWDG clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE);
/* WWDG clock counter = (PCLK1 (48MHz)/4096)/8 = 1464Hz (~683 us) */
WWDG_SetPrescaler(WWDG_Prescaler_8);
/* Set Window value to 80; WWDG counter should be refreshed only when the counter
is below 80 (and greater than 64) otherwise a reset will be generated */
WWDG_SetWindowValue(80);
/* Enable WWDG and set counter value to 127, WWDG timeout = ~683 us * 64 = 7 ms
In this case the refresh window is: ~683 * (127-80)= 1ms < refresh window < ~683 * 64 = 7ms
*/
WWDG_Enable(127);
while (1)
{
/* Toggle LED2 */
STM_EVAL_LEDToggle(LED2);
/* Insert 33 ms delay */
Delay(33);
/* Update WWDG counter */
WWDG_SetCounter(127);
}
2012-11-13 12:42 PM
Exactly my problem, I dont want to have to worry about setting the counter before I hit my window value and generating a reset because I hit the SetCounter statement too soon. All I want is to refresh the counter periodically without worrying if I am going to get there too soon. This is the watchdog implementation I am used, this getting there too soon is foreign to me. How do I work around it?
Basically, I want to SetCounter of my watchDog every 10 msec. If it gets past 1 sec, then reset. How do I do this?