STM32G070RBT6+cubemx+TIM6 定时中断

周期中断定时

cubemx配置

 

 

 

 

 

 

 

 

添加代码:

HAL_TIM_Base_Start_IT(&htim6);        //启动定时器TIM6


 

重载中断回调函数

 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
    static uint8_t num;
    if(htim->Instance == TIM6)                  //处理TIM6间隔定时中断
    {
                num++;//功能代码
    }
}

 

  

 

posted @ 2023-02-01 17:55  辛河  阅读(386)  评论(0)    收藏  举报