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.

1234567891011121314151617181920212223
  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); //ָIJʼTIMxʱλ
  14. TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE ); //ʹָTIM3ж,ж
  15. TIM_Cmd(TIM3, ENABLE); //ʹTIMx
  16. }