gfroerli / firmware

Firmware for the water temperature sensor project
GNU General Public License v3.0
6 stars 1 forks source link

Clock setup #50

Open dbrgn opened 4 years ago

dbrgn commented 4 years ago

Use the external clock, if it makes sense.

dbrgn commented 4 years ago

The LSE (Low Speed External) clock source is only used for certain use cases like low power timers, the RTC, etc. It can't be used as sysclock, it's only a secondary clock.

Right now we're using the HSI (High Speed Internal) clock at 16 MHz. I tried switching to MSI (Multi Speed Internal):

let mut rcc = dp.RCC.freeze(
    hal::rcc::Config::msi(hal::rcc::MSIRange::Range5) // ~2.097 MHz
);

This is also the default configuration after reset. However, with that config the timer (TIM6) could not be initialized anymore (it hangs). We should probably investigate what the problem is.

@rnestler what are tradeoffs of faster/slower clock speed? Slower speeds use less energy but take longer to get things done, right? How can we decide whether HSI or MSI with a slower clock is better?

Also, when does one use the PLL instead?

dbrgn commented 2 years ago

@rnestler ping!