You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 satır
865B

  1. #include "tim.h"
  2. //------------------------------------------------------------------
  3. void TIM3_Int_Init(u16 arr,u16 psc)
  4. {
  5. TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  6. // NVIC_InitTypeDef NVIC_InitStructure;
  7. RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); //时钟使能
  8. //定时器TIM3初始化
  9. TIM_TimeBaseStructure.TIM_Period = arr; //设置在下一个更新事件装入活动的自动重装载寄存器周期的值
  10. TIM_TimeBaseStructure.TIM_Prescaler =psc; //设置用来作为TIMx时钟频率除数的预分频值
  11. TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置时钟分割:TDTS = Tck_tim
  12. TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //TIM向上计数模式
  13. TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); //根据指定的参数初始化TIMx的时间基数单位
  14. TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); //使能指定的TIM3中断,允许更新中断
  15. TIM_Cmd(TIM3, ENABLE); //使能TIMx
  16. }