本帖最后由 175192387 于 2019-4-4 21:48 编辑
过零检测电路,设置了过零中断,我发现程序一直未进入中断。
这是示波器的图
void EXTIX_Init(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
KEY_Init(); // 按键端口初始化
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); //使能复用功能时钟
//GPIOB.14 中断线以及中断初始化配置
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource14);
EXTI_InitStructure.EXTI_Line=EXTI_Line14;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure); //根据EXTI_InitStruct中指定的参数初始化外设EXTI寄存器
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //抢占优先级2,
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中断通道
NVIC_Init(&NVIC_InitStructure);
}
//外部中断0服务程序
void EXTI15_10_IRQHandler(void)
{
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_14)==1)
{
UPWM=1;
EXTI_ClearITPendingBit(EXTI_Line14);
}
if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_14)==0)
{
num=0;
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); //开启定时器中断
EXTI_ClearITPendingBit(EXTI_Line14);
}
}
|