How can I sync a custom TIM to the same timer being used for the Ticker class?

I wrote a custom STM32 timer driver in Input Capture mode so that I could sync a Ticker object interrupt to an external signal.

I assumed that I could take the input capture value and use it to set the interrupt like so:

ticker.attach_us(myFunc, inputCapture);

However, I quickly found out that in order for the Ticker class to be in sync with my custom timer used for input capture, they would both need to be clocked from the same clock source.

To my understanding, the STM32F446RE system clock configuration is set to at 180MHz, but how can I find out the clock rate for MBEDs timers / ticker class? I imagine they have their own prescalers values.

I think if I match the same prescaler values of MBEDs timers with my custom timer, I should be ok - anyone know where I can find this information?

Hello Scott,

Ticker objects are driven by Mbed’s us ticker. You can figure out which timer is used for that function in case of an STM32F446RE target in the mbed-os/targets/TARGET_STM/TARGET_STM32F4/us_ticker_data.h file:

...
#define TIM_MST      TIM5
...

To get the timer’s settings (prescaler values etc.) open the mbed-os/targets/TARGET_STM/us_ticker.c file.

I have never tried to synchronize other timers with the us timer but I hope this might help you to accomplish that.

1 Like

Is there a reason the MBED Timer class doesn’t support some of these more advanced features?

Is it because other non-stm microcontrollers may not support them?