请大家帮忙看看下面的程序,用TIMER4的输入捕获去红外解码,中断服务函数中,TIM_GetITStatus(TIM4, TIM_IT_Update) 能成立,而,中断服务函数中 红色加粗部分的 if(TIM_GetITStatus(TIM4, TIM_IT_CC4) != RESET)怎么都不成立,请教是哪里没初始化好,还是什么, 先谢谢了。。 //红外遥控初始化 //设置IO以及定时器4的输入捕获 void Remote_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_ICInitTypeDef TIM_ICInitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOG, ENABLE); //使能PORTG时钟 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE); //TIM4 时钟使能 #if 0 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //PB9 输入 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_SetBits(GPIOG, GPIO_Pin_1); //初始化GPIOB.9 #endif TIM_TimeBaseStructure.TIM_Period = 10000; //设定计数器自动重装值 最大10ms溢出 TIM_TimeBaseStructure.TIM_Prescaler = (72 - 1); //预分频器,1M的计数频率,1us加1. TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置时钟分割:TDTS = Tck_tim TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM向上计数模式 TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx TIM_ICInitStructure.TIM_Channel = TIM_Channel_4; // 选择输入端 IC4映射到TI4上 TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; //上升沿捕获 TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; //配置输入分频,不分频 TIM_ICInitStructure.TIM_ICFilter = 0x03;//IC4F=0011 配置输入滤波器 8个定时器时钟周期滤波 TIM_ICInit(TIM4, &TIM_ICInitStructure);//初始化定时器输入捕获通道 NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn; //TIM3中断 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //先占优先级0级 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //从优先级3级 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道被使能 NVIC_Init(&NVIC_InitStructure); //根据NVIC_InitStruct中指定的参数初始化外设NVIC寄存器 TIM_ITConfig( TIM4, TIM_IT_Update | TIM_IT_CC4, ENABLE); //允许更新中断 ,允许CC4IE捕获中断 TIM_Cmd(TIM4, ENABLE ); //使能定时器4 } 这是中断服务函数。 void TIM4_IRQHandler(void) { if (u16TestCounter++ > 10) { //LED = !LED; u16TestCounter = 0; } if(TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET) { aa++; if(RmtSta & 0x80) //上次有数据被接收到了 { RmtSta &= ~0X10; //取消上升沿已经被捕获标记 if((RmtSta & 0X0F) == 0X00)RmtSta |= 1 |