cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 PWM output lags [SOLVED]

zexx86
Associate II
Posted on March 27, 2014 at 16:23

Hello

My STM32F103RBT6 has problem with PWM output (TIM2 CH4) as servo control.

This problem only occuring while USART2 is processing interrupts because of received data.

Interestingly, there is also some parallel with SysTick.

Problem is, that PWM output is not updated in specified frequency, but only about 1Hz instead 100Hz.

Interestingly, when Systick is configured with SysTick_Config (SystemCoreClock / 10000), it is as I described. But when I change SysTick to be 10x slower (SystemCoreClock / 1000), then PWM output is updated cca 10x faster too (10Hz).

This problem only occur with USART2, USART1 and USART3 seems to be OK.

Sadly, I need USART2 because of own board.

Thanks for any help.

10 REPLIES 10
zexx86
Associate II
Posted on March 28, 2014 at 13:46

Finally I fixed the bug !!!

I examined ST's stdlibrary and found that for TIM1 and TIM8 it configures TIM_RepetitionCounter.

I think it could be very serious problem for others too.

Problem was only with uninitialised value for this parameter.

I configured it to 0 and all is perfect now.

Thanks again for help. I hope it could be helpfull for all.