2015-10-09 02:33 AM
Hello
I've a question regarding the timer synchronization on an STM32L4. I've setup TIM1 and TIM8 to run in synch triggered by TIM2. To test the code I simply toggle a pin inside the TIM1 and TIM8 update interrupts. As far as I can tell it seems to work, but two things worry me. When I debug the whole thing and set a breakpoint, the CNT register values of TIM1 and TIM8 are not equal, although my debug configuration definatly stops both timers when hitting the break. How could that be? I mean... they couldn't be off by much, judging from image #1... but still? And the other thing I find kinda strange is that it takes the controller between 400 and 500ns (see image #2) just to end one timer IRQ and jump into the next one. Is this jitter normal? Both IRQs are temporarily set to the highest priority, nothing else could preempt them...2015-10-09 03:08 AM
Have you or the debugger set respective TIMx_STOP bits in DBGMCU_APB2FZ? If not the timers are still running after breakpoint. You can verify it by refreshing the timers registers' view in the debugger.
If you wrote the pins change at the beginning-end of ISR in C, the comipler might have added a whole bunch of instructions as prologue/epilogue, depending on compiler, its settings, and the ISR code itself. JW2015-10-10 07:02 AM
The stop bits are set yes, thats why its bugging me...
Ok, so the jitter might ''normal''? All the ISR does is clearing the update flag and toggling the bit with direct register access. But I guess saving and restoring all context simply takes that long...