void iwdg_init(void)
{
//第一種方式
//? ? //使能獨(dú)立看門狗的寄存器能夠被修改
//? ? IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
//
//? ? //配置獨(dú)立看門狗的計(jì)數(shù)器
//? ? //獨(dú)立看門狗的硬件時(shí)鐘 = 40KHz / 256 = 156Hz
//? ? IWDG_SetPrescaler(IWDG_Prescaler_256);
//
//? ? IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
//? ? //設(shè)置獨(dú)立看門狗的重載值,
//? ? IWDG_SetReload(150-1); //大概1秒
//
//? ? IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
//? ? //重載計(jì)數(shù)器值
//? ? IWDG_ReloadCounter();
//
//? ? IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
//? ? //使能看門狗
//? ? IWDG_Enable();
//第2種方式
? ? ? ? RCC->RSTSCKR = RCC_LSION;
? ? ? ? while((RCC->RSTSCKR & RCC_LSIRDY) == 0);
? ? ? ? IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
? ? ? ? IWDG_SetPrescaler(IWDG_Prescaler_32);
? ? ? ? IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
? ? ? ? IWDG_SetReload(4000);
? ? ? ? IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
? ? ? ? IWDG_Enable();
? ? ? ? IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
? ? ? ? IWDG_ReloadCounter();
}