void Remote_Init(void)
{
TIM_IC_InitTypeDef TIM1_CH1Config;
TIM1_Handler.Instance=TIM1; //ͨÓö¨Ê±Æ÷1
TIM1_Handler.Init.Prescaler=215; //预分频器,1M的计数频率,1us加1
TIM1_Handler.Init.CounterMode=TIM_COUNTERMODE_UP; //ÏòÉϼÆÊýÆ÷
TIM1_Handler.Init.Period=10000; //×Ô¶¯×°ÔØÖµ
TIM1_Handler.Init.ClockDivision=TIM_CLOCKDIVISION_DIV1;
HAL_TIM_IC_Init(&TIM1_Handler);
//³õʼ»¯TIM1ÊäÈ벶»ñ²ÎÊý
TIM1_CH1Config.ICPolarity=TIM_ICPOLARITY_RISING; //ÉÏÉýÑز¶»ñ
TIM1_CH1Config.ICSelection=TIM_ICSELECTION_DIRECTTI;//Ó³Éäµ½TI1ÉÏ
TIM1_CH1Config.ICPrescaler=TIM_ICPSC_DIV1; //ÅäÖÃÊäÈë·ÖƵ£¬²»·ÖƵ
TIM1_CH1Config.ICFilter=0x03; //IC1F=0003 8¸ö¶¨Ê±Æ÷ʱÖÓÖÜÆÚÂ˲¨
HAL_TIM_IC_ConfigChannel(&TIM1_Handler,&TIM1_CH1Config,TIM_CHANNEL_1);//ÅäÖÃTIM1ͨµÀ1
HAL_TIM_IC_Start_IT(&TIM1_Handler,TIM_CHANNEL_1); //¿ªÊ¼²¶»ñTIM1µÄͨµÀ1
__HAL_TIM_ENABLE_IT(&TIM1_Handler,TIM_IT_UPDATE); //ʹÄܸüÐÂÖжÏ
}
有大神知道为什么是1M吗,APB2不是只有108M,怎么分频得到1M的?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>