cancel
Showing results for 
Search instead for 
Did you mean: 

how to update TIM_Period when timer i running

spa23
Associate III
Posted on September 09, 2012 at 21:55

Hi 

I need to be able to update the Period for a timer (TIM3) I though it was simple, but no.

I have tried :

else if(TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)

{

ledTimeBaseStructure.TIM_Period = newValue;

TIM_TimeBaseInit(TIM3, &ledTimeBaseStructure);

TIM_ClearITPendingBit(TIM3, TIM_IT_Update);

}

but without any look, the period should be around 1 sek, but it is around 1 – 2 ms.

There must be a simple solution, so I hope any one can help, thanks

/SPA
1 REPLY 1
Posted on September 09, 2012 at 22:10

TIM3->ARR = newValue;

Now it's only going to be in the second range if you have a suitably large prescale value so the time base is operating in the tens of kilohertz range. Both the prescale and period registers are typically 16-bit, with the implied range limitation they bring.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..