[mw_shl_code=c,true]void cap_Init(void)
{
irda_state = IR_STATE_IDLE;
irda_Index = 0;
cap_IO_Init();
//定时器周期1us
TIM2_TimeBaseInit(TIM2_PRESCALER_16, 0xffff);
// TIM2_Cmd(ENABLE);
//下降沿捕获
TIM2_ICInit(TIM2_CHANNEL_2, TIM2_ICPOLARITY_FALLING, TIM2_ICSELECTION_DIRECTTI, TIM2_ICPSC_DIV1, 0x0F);
//开启捕获2中断和更新中断
TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);
TIM2_ITConfig(TIM2_IT_CC2, ENABLE);
TIM2_ClearFlag(TIM2_FLAG_CC2);
TIM2_Cmd(ENABLE);
// TIM2_GenerateEvent(TIM2_EVENTSOURCE_CC2);
}[/mw_shl_code][mw_shl_code=c,true]void cap_IO_Init(void)
{
GPIO_DeInit(GPIOD);
GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_IN_PU_NO_IT);
//GPIO_Init(GPIOD, GPIO_PIN_3, GPIO_MODE_IN_PU_IT);
//EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD, EXTI_SENSITIVITY_FALL_ONLY);
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>