stm32-rs / stm32f7xx-hal

A Rust embedded-hal HAL for all MCUs in the STM32 F7 family
Apache License 2.0
117 stars 68 forks source link

Timer period is off by one #121

Open jonathanpallant opened 3 years ago

jonathanpallant commented 3 years ago

If you create a timer at, say, 250.khz() you will get a timer at very slightly less than that.

When you set the auto-reload register arr, you need to specify the last valid counter before it wraps to zero - i.e. one less than the period in clock cycles.