①iwdg.h:
#ifndef iwdg_h
#define iwdg_h
#include“sys.h”
void iwdg_init(u8 prer,u16 rlr);
#endif
②iwdg.c:
#include “iwdg.h”
void iwdg_init(u8 prer,u16 rlr)
{
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); //取消写保护
IWDG_SetPrescaler(prer); //设置分频系数
IWDG_SetReload(rlr); //设置重装载值
IWDG_ReloadCounter(); //喂狗
IWDG_Enable(); //使能看门狗
}
③ main:
#include “led.h”
#include “delay.h”
#include “key.h”
#include “sys.h”
#include “beep.h”
#include “iwdg.h”
int main(void)
{
①iwdg.h:
#ifndef iwdg_h
#define iwdg_h
#include“sys.h”
void iwdg_init(u8 prer,u16 rlr);
#endif
②iwdg.c:
#include “iwdg.h”
void iwdg_init(u8 prer,u16 rlr)
{
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable); //取消写保护
IWDG_SetPrescaler(prer); //设置分频系数
IWDG_SetReload(rlr); //设置重装载值
IWDG_ReloadCounter(); //喂狗
IWDG_Enable(); //使能看门狗
}
③ main:
#include “led.h”
#include “delay.h”
#include “key.h”
#include “sys.h”
#include “beep.h”
#include “iwdg.h”
int main(void)
{
举报