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.enter image description here

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?

  • \$\begingroup\$ Probably in the fine print details. Often one of them can't be used in all Vcore modes. Or to feed a PLL. Or be used as a fallback when the external clock fails. Even if you have a µC where it can do all of these, it could be for convenience of those upgrading from smaller/older µCs where they were these restrictions. \$\endgroup\$
    – PlasmaHH
    Oct 12, 2017 at 9:47
  • \$\begingroup\$ Please include the actual STM32 part number. All STM32s are not alike and the part number would at least allow people to reference the correct datasheet and reference manual. Providing a link to those would also be helpful. \$\endgroup\$
    – Tut
    Oct 12, 2017 at 11:02
  • \$\begingroup\$ Thankyou, I've included the part number in the original post above. It's the STM32L496ZG. Page 38 has the clock tree. To me it looks fairly flexible with only the MSI so yes it must be in the fine print. I'm just hoping avoide that "ahhh moment" 3 months down the track. \$\endgroup\$ Oct 12, 2017 at 12:53

1 Answer 1


HSI is way more accurate, while being less flexible.

Looking at the highlighted values in the datasheet, MSI frequency becomes extremely unreliable at the lower ends of the temperature and the supply voltage range, while HSI would barely notice VDD dropping from 3.6V to 1.8V.

Therefore it is quite surprising that you were having problems with HSI as a clock source. Adding a bit in the middle would mean about 20% clock drift. That's a magnitude worse than the theoretical worst case accuracy of the HSI. There must be some other issue still lurking.

It is also worth noting that HSI16 can run in the STOP modes, but MSI can't.


  • \$\begingroup\$ Thanks for the clear explanation. Back to the drawing board for me. \$\endgroup\$ Oct 15, 2017 at 20:44
  • \$\begingroup\$ And thanks again. I've now solved my other issue which was related to the HSI calibration trimming value. The cubeMx software I was using to configure my project was issuing an incorrect default value causing the timing to go right out. It was this issue here. community.st.com/thread/41287-stm32l452ceu6-hsi-problem \$\endgroup\$ Oct 16, 2017 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.