In a ST microcontroller I'm using there are two OSC's that can be routed to exactly the same hardware and I'm wondering when you would use each one.
Link to part documentation STM32L496ZG
Excerpt from the data sheet about the two OSC's -
-16 MHz high-speed internal RC oscillator (HSI16), trimmable by software, that can supply a PLL
– Multispeed internal RC oscillator
(MSI), trimmable by software, able to generate 12 frequencies from 100 kHz to 48 MHz. When a 32.768 kHz clock source is available in the system (LSE), the MSI frequency can be automatically trimmed by hardware to reach better than ±0.25% accuracy. In this mode the MSI can feed the USB device, saving the need of an external high-speed crystal (HSE). The MSI can supply a PLL.
ST AN4555 Application Note explains
HSI16 clock
The HSI16 clock signal is generated from an internal 16 MHz RC Oscillator. The HSI16 RC oscillator has the advantage of providing a clock source at low cost (no external components). It also has a faster startup time than the HSE crystal oscillator however, even with calibration the frequency is less accurate than an external crystal oscillator or ceramic resonator. The HSI16 signal can also be used as a backup source (Auxiliary clock) if the HSE crystal oscillator fails. Refer to reference manual section: Clock security system (CSS).
3.3 MSI clock
The MSI clock signal is generated from an internal RC oscillator. Its frequency range can be adjusted by software by using the MSIRANGE[3:0] bits in the Clock control register (RCC_CR). Twelve frequency ranges are available: 100 kHz, 200 kHz, 400 kHz, 800 kHz, 1 MHz, 2 MHz, 4 MHz (default value), 8 MHz, 16 MHz, 24 MHz, 32 MHz and 48 MHz. The MSI RC oscillator has the advantage of providing a low-cost (no external components) low-power clock source. In addition, when trimmed by the 32.768 kHz external oscillator (LSE), the MSI can provide the USB device with very accurate clock removing the need for an external high speed crystal (HSE).
My problem
I've been pulling my hair out as the STLINK LPUART was adding an extra zero in the middle of each byte that I sent to the PC from the micro controller. I put it down to timing and I realised that I had assigned HSI as the LPUART clock. When I assigned MSI the error disappeared. I assume I'll need to trim the HSI as it must need calibration.
But this got me wondering, as I can use the MSI for just about anything, why do they include both clocks in the single chip?