APB1 and APB2 are out of sync
I'm using STM32F446.
I'm generating PWM signals using TIM1 and TIM8 (on APB2, which runs at 90MHz, and 180MHz for the timers).
I'm also generating PWM signals using TIM4 and TIM12 (on APB1, which runs at 45MHz, and 90MHz for the timers).
I start each PWM independently, so their starting edges are not synchronized, but this is not the point.
TIM1 and TIM8 are "in sync" in the sense that the shift between the two signals remains perfectly constant, with no drift whatsoever.
TIM4 and TIM12 are also "in sync" in this sense.
However, TIM1-8 and TIM4-12 are not in sync with each other; their relative phase shifts around in an unpredictable way, and quite quickly. I'm not sure whether it's just jitter (i.e. the drift averages to 0 over a long period of time) or the drift diverges.
Of course I'm prescaling TIM1-8 by 2, so that the counting frequency is the same as that of TIM4-12.
Even if I change the APB2 prescaler so that the two buses are at the same frequency, the out-of-sync behavior persists.
I would assume that APB1 and APB2 should never have any relative jitter in their frequency, since they are both derived from the same clock (HCLK), just scaled differently.
So, why do I observe the behavior explained above?
Is it expected? Is there any way to sync APB1 and APB2 perfectly?
Could I avoid the PWM problem by chaining the timers together, so that one single timer (possibly a basic one?) can generate the counting base, which is then consumed by all the other timers (TIM1-4-8-12), so that they are in sync?
Edit: there is a similar issue for STM32F746:
which never had any reply
