STM8S TIM4库函数应用

void TIM4_TimerInit(u8 Timer4Time)
{
  assert_param(IS_TIM4TIMERTIME_OK(Timer4Time));
   
  TIM4_DeInit();//复位TIM4全部參数
  TIM4_TimeBaseInit(TIM4_PRESCALER_16,Timer4Time);//16M/16= 1M CYCLE=1/1=1U 100us中断一次
  //选择16分频 16M/16=1M  周期为1us 
  TIM4_Cmd(ENABLE);//使能计时器
  TIM4_ITConfig(TIM4_IT_UPDATE,ENABLE);//使能TIM4中断
}

初始化时,调用:
TIM4_TimerInit(125)//定时125us中断一次

你可能感兴趣的:(函数)