STM32F0_HAL初始化系列:输入捕捉
作者:互联网
1.使用的TIM1,配置如下:
2.代码:
int main(void) { HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_TIM1_Init(); MX_TIM14_Init(); //HAL_TIM_Base_Start_IT(&htim14); //开始定时器 HAL_TIM_Base_Start_IT(&htim1); HAL_TIM_IC_Start_IT(&htim1,TIM_CHANNEL_2); HAL_TIM_IC_Start_IT(&htim1,TIM_CHANNEL_3); //HAL_TIM_IC_Stop_IT while (1) { } } //输入捕获中断 void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) { uint16_t temp = 0; if( htim ->Channel == HAL_TIM_ACTIVE_CHANNEL_2 ) //通道2 A相
{
TIM1->CCR2;
}
else if( htim ->Channel == HAL_TIM_ACTIVE_CHANNEL_2 )
{
TIM1->CCR3;
}
}
//更新中断 void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { }
标签:初始化,TIM1,HAL,htim,TIM,Init,IC,STM32F0 来源: https://www.cnblogs.com/penuel/p/11288107.html