本人选用了两个定时器,分别为TIM1和TIM3,其产生捕获中断和更新中断,现在遇到一个问题:任意只开启一个中断,程序正常运行,两个中断都打开则程序只会进一次主循环(while死循环)?查了半天都没有发现原因,是不能这样用吗?还是其他原因呢 配置如下: void MX_TIM3_Init(void) { TIM_MasterConfigTypeDef sMasterConfig; TIM_ClockConfigTypeDef sClockSourceConfig; htim3.Instance = TIM3; htim3.Init.Period = T3_PERIOD; htim3.Init.Prescaler = T3_PRESCALER; htim3.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED1; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; HAL_TIM_Base_Init(&htim3); sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig); } void MX_TIM1_Init(void) { TIM_MasterConfigTypeDef sMasterConfig; TIM_OC_InitTypeDef sConfigOC; TIM_ClockConfigTypeDef sClockSourceConfig; TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig; htim1.Instance = TIM1; htim1.Init.Period = T_PERIOD; htim1.Init.Prescaler = T_PRESCALER; htim1.Init.CounterMode = TIM_COUNTERMODE_CENTERALIGNED1; htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim1.Init.RepetitionCounter = T_REPETITIONCOUNTER; HAL_TIM_Base_Init(&htim1); sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC3REF; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig); sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig); } void TIM1_CC_IRQHandler(void) { HAL_TIM_IRQHandler(&htim1); } void TIM3_IRQHandler(void) { HAL_TIM_IRQHandler(&htim3); } |
哪里有错位?没看出来。能具体点吗