stm32-rs / stm32f0xx-hal

A Rust `embedded-hal` implementation for all MCUs in the STM32 F0 family
BSD Zero Clause License
134 stars 59 forks source link

More precise units for timers. #140

Closed agausmann closed 3 years ago

agausmann commented 3 years ago

Timers are currently implemented with type Time = Hertz. Besides the obvious oddity of using frequency as the unit for timeout times, the Hertz wrapper type is also limited to integer values, which severely restricts the possible periods/frequencies that can be set for a timer.

This isn't a problem at the kHz or MHz scale, but at low audible frequencies (like the low end of the range of MIDI music notes), it's just not enough precision. At the very lowest values, the differences between frequencies are <1Hz, and above those, the frequencies are still noticeably out of tune until they reach a scale where integers provide enough precision.

agausmann commented 3 years ago

Moved to stm32-rs/meta#7