|
应师兄的要求,在X3板子上面测试了下,定时器个更新中断功能,发现的确存在调用开启更新中断就会进入一次IRQ的问题。
测试API和IRQ
void TIM8_MeasureConfig(void)
{
TIM_TimeBaseInitTypeDef TIM_BaseInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable the TIM8 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM8_UP_TIM13_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* 开启时钟 */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
/* 定时器配置 */
TIM_DeInit(TIM8);
TIM_BaseInitStructure.TIM_Period = 8400;
TIM_BaseInitStructure.TIM_Prescaler = 0;
TIM_BaseInitStructure.TIM_ClockDivision = 0;
TIM_BaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM8, &TIM_BaseInitStructure);
TIM_Cmd(TIM8, DISABLE); //关闭的情况下依然可以进入一次中断,真是感觉很奇葩。
TIM_ITConfig(TIM8, TIM_IT_Update, ENABLE); //关闭这个的话,就不会再进入了。
}
*************************************************************************************************************************
uint8_t flag = 0;
void TIM8_UP_TIM13_IRQHandler(void)
{
if (TIM_GetITStatus(TIM8, TIM_IT_Update) != RESET)
{
printf(" wwww = %d\r\n", flag++);
TIM_ClearITPendingBit(TIM8, TIM_IT_Update);
}
}
*************************************************************************************************************************
|
|