Files
CHJ/user/MCU/lhl_watchdog.c
2026-03-20 21:19:04 +08:00

39 lines
1.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "../main/SystemInclude.h"
/*==========================================
IWDG
==========================================*/
//iwdg_cfg(IWDG_PRESCALER_t IWDG_PRESCALER,uint16_t Reload)
void iwdg_cfg(void)
{
// 1. IWDG上电后默认是运行状态时钟源32K LSI默认复位周期约20秒
LHL_IWDG_Stop();
// 2. 写入WDG必须先解锁注意WDG一旦Reload就自动启用写保护
LHL_IWDG_Unlock();
// 3. 设定LSI 32分频约1KHz默认为256分频
LHL_IWDG_SetPrescaler(IWDG_PRESCALER_32, LHL_NRM_TIMEOUT);
// 4. IWDG是12bit寄存器最大值4095默认重装载值0x9C0
LHL_IWDG_SetReload(4000, LHL_NRM_TIMEOUT);
// 5. 自动装载并开始运行大约4000*1KHz=4S复位
LHL_IWDG_Start();
}
/*
//void LHL_IWDG_Reload(void);//写入0xAAAA重装载IWDG
//LHL_StatusTypeDef LHL_IWDG_Stop(void); //暂停运行IWDG
//LHL_StatusTypeDef LHL_IWDG_Resume(void);//继续运行IWDG
//LHL_StatusTypeDef LHL_IWDG_Start(void);//写入0xAAAA重装载并启动IWDG
*/
void stop_WDT(void)
{
LHL_IWDG_Stop();
}
void clear_WDT(void)
{
//LHL_IWDG_Reload();
}