关于ucos系统下STM32看门狗的使用问题! 目前我的使用方法为: 配置过程: void Wdg_Init(void) { // Enable WDG clocks RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG , ENABLE); // PCKL1: 36MHZ // WWDG clock counter = (PCLK1/4096)/8 = 488 Hz (~2 ms) WWDG_SetPrescaler(WWDG_Prescaler_8); // Set Window value to 65 WWDG_SetWindowValue(65); // Enable WWDG and set counter value to 127, WWDG timeout = ~2 ms * 64 = 130 ms WWDG_Enable(127); // Clear EWI flag WWDG_ClearFlag(); //Enable EW interrupt WWDG_EnableIT(); } 在中断中使用: void WWDG_IRQHandler(void) { OS_CPU_SR cpu_sr; OS_ENTER_CRITICAL(); //Tell uC/OS-II that we are starting an ISR OSIntNesting++; OS_EXIT_CRITICAL(); // Update WWDG counter if(wdg_clr_flag == 1) { WWDG_SetCounter(0x7F); wdg_clr_flag = 0; } // Clear EWI flag WWDG_ClearFlag(); OSIntExit(); // Tell uC/OS-II that we are leaving the ISR } wdg_clr_flag 这个标志是在钩子函数中设置 extern volatile unsigned long wdg_clr_flag; void OSTaskIdleHook (void) { wdg_clr_flag = 1; } 我想知道大家都是怎么用的!大家可以和我讨论一下吗? |