void iwdg_init(void)
{
//第一种方式
// //使能独立看门狗的寄存器能够被修改
// IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
//
// //配置独立看门狗的计数器
// //独立看门狗的硬件时钟 = 40KHz / 256 = 156Hz
// IWDG_SetPrescaler(IWDG_Prescaler_256);
//
// IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
// //设置独立看门狗的重载值,
// IWDG_SetReload(150-1); //大概1秒
//
// IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
// //重载计数器值
// 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();
}