初级会员

- 积分
- 62
- 金钱
- 62
- 注册时间
- 2022-1-11
- 在线时间
- 17 小时
|
wwdg.c:
#include "wwdg.h"
#include "sys.h"
u8 WWDG_CNT=0x7f;
void My_WWDG_Init(u8 tr,u8 wr,u32 fprer)
{
u8 WWDG_CNT=tr&0x7f;//防止tr溢出
RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG,ENABLE);
WWDG_SetPrescaler(fprer);
WWDG_SetWindowValue(wr);
WWDG_Enable(WWDG_CNT);
WWDG_ClearFlag();
My_WWDG_NVIC_Init();
WWDG_EnableIT();
}
void My_WWDG_NVIC_Init(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = WWDG_IRQn; //WWDG 中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; //抢占 2 子优先级 3 组 2
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //抢占 2,子优先级 3,组 2
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void WWDG_IRQHandler(void)
{
delay_init();
WWDG_SetCounter(WWDG_CNT); //当禁掉此句后,窗口看门狗将产生复位
WWDG_ClearFlag(); //清除提前唤醒中断标志位
PEout(5)=!PEout(5); //LED 状态翻转
PBout(8)=!PBout(8);
delay_ms(50);
//PBout(5)=1;
}
main.c:
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "beep.h"
#include "iwdg.h"
#include "wwdg.h"
#define LED_0 PBout(5);
#define LED_1 PEout(5);
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init();
BEEP_Init();
void LED_Init(void);
LED_Init();
PBout(5)=0;
//delay_ms(300);
My_WWDG_Init(0X7F,0X5F,WWDG_Prescaler_8);
while(1);
{
PBout(5)=1;
}
}
请问是否有大佬可以解惑,我的程序为什么在标红处的PBout(5)被注释掉后DS0无法熄灭。
|
|