AnsweredAssumed Answered

STM32F746ZG Timer accuracy and jitter

Question asked by Matt Jackson on Jul 21, 2017
Latest reply on Jul 21, 2017 by Matt Jackson

Hi there, 


I have a Nucleo F746ZG board and am experimenting with the peripherals.  I'm trying to get a regular timer interrupt at a given frequency, and am seeing a huge amount of jitter.


Here's my configuration:


  • System Clock 216MHz (16MHz Xtal w/ PLL)
  • SPI full duplex with interrupt priority level 1 (I have tried disabling SPI, it did not help)
  • Timer 3 channel 1 in output compare timing mode, with interrupt priority level 0
  • Timer clock 18MHz
  • Timer Prescaler set to 52245, which should give me an interrupt frequency of 344.5305770887 Hz


In the interrupt I do this:


void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)


         HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_11);



I am then analysing pin B11 on a scope. I would expect to see a frequency of 172.26528.    

What I'm measuring is anywhere between 174.6 - 174.9 Hz.  It's all over the place.


The SPI interrupt is a lower priority, so shouldn't affect it, but I've tried disabling it anyway, and that didn't help. No other timers or timer channels are enabled, so it should only be TIM3 channel 1 triggering this interrupt.


There's nothing else happening on the chip.  I presume it's possible to get better accuracy than this!


Any help would be greatly appreciated.