STM32f103c8中使用定时器,在外部中断服务函数中开启定时器,定时器中断服务函数中关闭定时器中断,遇到问题:调试时可以进入定时器中断服务函数,在实际运行的时候不能进入中断服务函数,很揪心的问题,以前也遇到类似的问题,到底是在什么情况下会产生这种状况,如何避免?- void EXti1_IRQHandler(void)
- {
- /* USER CODE BEGIN EXTI1_IRQn 0 */
- /* USER CODE END EXTI1_IRQn 0 */
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
- /* USER CODE BEGIN EXTI1_IRQn 1 */
- //estimate DIM1 and DIM2 state
- //if DIM1 ON,initialize tim3,begin count
- //if DIM2 ON,initialize tim4,begin count
- if(dim1state)
- {
- DIM1 = DIM1_ON;
- // TIM3->CNT = 0;
- TIM3->ARR = set1v;
- TIM3->DIER |= 1;
- TIM3->CR1 |= (1<<0);
- }
- if(dim2state)
- {
- DIM2 = DIM2_ON;
- // TIM4->CNT = 0;
- TIM4->ARR = set2v;
- TIM4->DIER |= 1;
- TIM4->CR1 |= (1<<0);
- }
- // Tragflog = 1;
- /* USER CODE END EXTI1_IRQn 1 */
- }
- void TIM3_IRQHandler(void)
- {
- /* USER CODE BEGIN TIM3_IRQn 0 */
- /* USER CODE END TIM3_IRQn 0 */
- HAL_TIM_IRQHandler(&htim3);
- /* USER CODE BEGIN TIM3_IRQn 1 */
- if(TIM3->SR&0x0001)
- {
- //DIM1_OFF
- //stop tim3
- TIM3->DIER &= ~(1<<0);
- DIM1 = DIM1_OFF;
-
- }TIM3->SR &= ~(1<<0);
- /* USER CODE END TIM3_IRQn 1 */
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>