AnsweredAssumed Answered

STM32F103 TIM3 Timebase problem?

Question asked by KraigK on Aug 21, 2013
Latest reply on Aug 21, 2013 by Clive One
My timebase for TIM3 does seem to obey the laws of timebase calculation! I think I've had this problem before, what am I doing wrong.


  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

  /* TIM3 clock enable */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);

  /* Time Base configuration */
  TIM_TimeBaseStructure.TIM_Prescaler = 36000 - 1;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period = 10 - 1;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
  TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

  /* TIM enable counter */

  /* Enable the Interrupt Request */
  TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);

And in my ISR:

  GPIOB->ODR ^= GPIO_Pin_0;

  TIM_ClearITPendingBit(TIM3, TIM_IT_Update);

When I use the above, the pulse width of my trace on PB0 is 5ms. Shouldn't it be 10ms?

Also when I use Pre = 36000 and Period of anything greater than 2000, the ISR never fires. I'm trying to get a toggle greater than 1sec.