STM8L的看门狗: (1) 使用内部的低速时钟(LSI):38K,同时设置了4-256的分频,所以可以设置时间为0.1ms-1724.63ms; (2)IWDG_KR=0XCC 使能,IWDG_KR = 0XAA喂狗 ,IWDG_KR = 0X55允许访问IWDG_PR(预分频) 和 IWDG_RLR(看门狗初始值) void IWDG_Init(void)
{
CLK_LSICmd(ENABLE);
while (CLK_GetFlagStatus(CLK_FLAG_LSIRDY) == RESET);
CLK_BEEPClockConfig(CLK_BEEPCLKSource_LSI);
CLK_PeripheralClockConfig(CLK_Peripheral_BEEP, ENABLE);
IWDG_Enable();//记得先使能
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
IWDG_SetPrescaler(IWDG_Prescaler_256);
IWDG_SetReload((uint8_t)RELOAD_VALUE);//RELOAD_VALUE=254 1.724s
IWDG_ReloadCounter(); }
|