【求助】307定時器無法進(jìn)入更新中斷

使用TIM10,能夠進(jìn)入比較中斷,進(jìn)不了更新中斷

void?TIM10_CC_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast")));
void?TIM10_UP_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast")));

uint32_t?RPM?=?0;
uint8_t?TimeOutNum=0;

void?RPM_Sensor_Init(?u16?arr,?u16?psc?)
{
????GPIO_InitTypeDef?GPIO_InitStructure={0};
????TIM_ICInitTypeDef?TIM_ICInitStructure={0};
????TIM_TimeBaseInitTypeDef?TIM_TimeBaseInitStructure={0};
????NVIC_InitTypeDef?NVIC_InitStructure={0};

????RCC_APB2PeriphClockCmd(?RCC_APB2Periph_GPIOB?|?RCC_APB2Periph_TIM10,?ENABLE?);

????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_8;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
????GPIO_Init(?GPIOB,?&GPIO_InitStructure);
????GPIO_ResetBits(?GPIOB,?GPIO_Pin_8?);

????TIM_TimeBaseInitStructure.TIM_Period?=?arr;
????TIM_TimeBaseInitStructure.TIM_Prescaler?=?psc;
????TIM_TimeBaseInitStructure.TIM_ClockDivision?=?TIM_CKD_DIV1;
????TIM_TimeBaseInitStructure.TIM_CounterMode?=?TIM_CounterMode_Up;
????TIM_TimeBaseInitStructure.TIM_RepetitionCounter?=??0x00;
????TIM_TimeBaseInit(?TIM10,?&TIM_TimeBaseInitStructure);

????TIM_ICInitStructure.TIM_Channel?=?TIM_Channel_1;
????TIM_ICInitStructure.TIM_ICPrescaler?=?TIM_ICPSC_DIV1;
????TIM_ICInitStructure.TIM_ICFilter?=?0x00;
????TIM_ICInitStructure.TIM_ICPolarity?=?TIM_ICPolarity_Rising;
????TIM_ICInitStructure.TIM_ICSelection?=?TIM_ICSelection_DirectTI;

????TIM_PWMIConfig(?TIM10,?&TIM_ICInitStructure?);

????NVIC_InitStructure.NVIC_IRQChannel?=?TIM10_CC_IRQn;
????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?2;
????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?0;
????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;
????NVIC_Init(&NVIC_InitStructure);

????TIM_ITConfig(?TIM10,?TIM_IT_CC1,?ENABLE?);
????TIM_ITConfig(?TIM10,?TIM_IT_Update,?ENABLE?);

????TIM_SelectInputTrigger(?TIM10,?TIM_TS_TI1FP1?);
????TIM_SelectSlaveMode(?TIM10,?TIM_SlaveMode_Reset?);
????TIM_SelectMasterSlaveMode(?TIM10,?TIM_MasterSlaveMode_Enable?);
????TIM_Cmd(?TIM10,?ENABLE?);
}

void?TIM10_CC_IRQHandler(void)
{
????if(?TIM_GetITStatus(?TIM10,?TIM_IT_CC1?)?!=?RESET?)
????{
????????RPM?=?(uint32_t)(1000000/TIM_GetCapture1(?TIM10?)*60);
????????TimeOutNum?=?0;
????????TIM_ClearITPendingBit(?TIM10,?TIM_IT_CC1);
????}
}

void?TIM10_UP_IRQHandler(void)
{
????if?(TIM_GetITStatus(TIM10,?TIM_IT_Update)?==?SET)
????{
????????TIM_ClearITPendingBit(TIM10,?TIM_IT_Update);
????????TimeOutNum++;
????????if?(TimeOutNum>5)?RPM=0;
????}
}


您好,注意添加對更新中斷的優(yōu)先級相關(guān)及使能配置,如下圖

image.png


非常感謝,是我大意了,之前把兩個標(biāo)志位判斷放在一個中斷函數(shù)里,后來注意到需要分開寫中斷函數(shù),但是還是忘了把更新中斷添加到NVIC里


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频