HSI vs HSE — what are the tradeoffs?
The HSI (High-Speed Internal) oscillator is an on-chip RC oscillator that requires no external components and starts within microseconds of being enabled. Its typical accuracy is plus or minus 1% at room temperature (25 degrees C), degrading to plus or minus 2-3% over the full temperature range (-40 to 85 degrees C). The HSI is always available, making it ideal as a safe fallback clock source — if the external crystal fails, the system can revert to HSI and continue operating in a degraded mode. For applications that do not require precise timing — GPIO toggling, ADC sampling with timer triggers, motor control where the control loop compensates for clock drift — HSI is perfectly adequate and saves BOM cost (no crystal, no load capacitors, no PCB routing constraints).
The HSE (High-Speed External) oscillator uses an external crystal or ceramic resonator, requiring two pins and two load capacitors (typically 10-20 pF). Its accuracy depends on the crystal: a standard 8 MHz crystal provides plus or minus 20 ppm (0.002%) accuracy — roughly 50x better than HSI. The HSE takes 2-10 ms to start and stabilize (the crystal needs time to build oscillation amplitude), which is a consideration for ultra-fast wake-up scenarios. The HSE is mandatory for certain peripherals: USB requires a 48 MHz clock derived from PLL with HSE accuracy (HSI drift exceeds the USB plus or minus 0.25% tolerance), CAN requires plus or minus 0.5% clock accuracy that HSI cannot guarantee across temperature, and Ethernet needs a 25 MHz reference that is typically derived from the HSE.
The decision comes down to the application's timing requirements: if you use USB, CAN, Ethernet, or any protocol with tight baud rate tolerance, you need HSE. If you use UART at moderate baud rates (up to 115200), HSI is usually acceptable — at 1% error, the worst-case bit timing error is within the UART's 3-5% tolerance at low baud rates but may fail at 1 Mbaud or higher. A practical middle ground on some STM32 families is the HSI with calibration trimming — the HSITRIM bits in RCC_CR allow fine-tuning the HSI frequency in approximately 40 kHz steps. Some applications measure HSI against an external timing reference (like a GPS 1PPS signal or an RTC with a 32.768 kHz crystal) and dynamically adjust HSITRIM for sub-0.1% accuracy without a high-speed crystal.
Source: MCU Cores & Clocking Q&A
