AnsweredAssumed Answered

STM32F103RF: Timer generates "Update Interupt" too early

Question asked by p.denis.001 on Feb 1, 2016
Latest reply on Feb 1, 2016 by Clive One
IAR Embedded Workbench

Consider timer TIM7 initialized and started in some IRQ handler in the next sequence:
void SOME_IRQ_Handler(void)
{
TIM7->PSC = some_value;
TIM7->ARR = some_value;
TIM7->EGR |= TIM_EGR_UG;
TIM7->SR = 0;
TIM7->DIER = TIM_DIER_UIE;
TIM7->CR1 |= TIM_CR1_CEN;
}
And timer's IRQ is:
void TIM_IRQ_Handler(void)
{
// toggle gpio port on each irq event (PC6 in my case)
}
Consider two cases:
1. some_value = 0x100;
2. some_value = 0xFFFF;
Measure and compare the first period (exactly after enabling the timer) to the second with the scope in both cases.
My questions:
1. Is duration of the 1 period in both cases are the same? In my case the answer is YES!
2. Is duration of the first period is equal to the second, third ..... in both cases respectively? In my case the answer is NO!
In my case the first period is less then should be (in both cases) and has a fixed value
3. Have I missed something? Did anyone had to deal with the same or similar problem?
4. If it's still a problem, how can I solve it?

PS:
- SOME_IRQ_Handler has a lower interrupt priority
- Problem is invariant to the timer used

Outcomes