- Muchas notas - Fran Acién

20240417 - STM32 Timers and clocks

Ey Ya All!! I need to configure a timer on STM32, and here I am going to show how to do it. I am following this Source.

I need to create a clock with the next properties:

  • Timer activated every 10 KHz, 100us
  • Original clock is 84 MHz

In that case the math would be: $$ F_{MainClock} = \text{Prescaler} \cdot \text{CounterPeriod} \ f_{tickTimer} = F_{MainClock} / \text{Prescaler} \ f_{timer} = f_{tickTimer} / T_{Counter} $$ The Counter Period can be up to a maximum of 65535. Lets fix the Prescaler to 840. Then the TCounter would be 10.

Remember that in the value of the software you need to put 3000-1, because it counts from 0.