STM32C091CCT6 – Timer period measured ~995 ms instead of configured 1000 ms using HSI @ 48 MHz
We are using an STM32C091CCT6 with the internal HSI (48 MHz) configured as the system clock.
Our application generates a volume-based pulse output using TIM14 in one-shot compare mode. The output pulse frequency is derived from flow rate, and the receiving equipment measures the number of pulses generated per second. Therefore, maintaining an accurate 1-second timing window is important for correct pulse frequency and flow indication.
Timer Configuration
- MCU: STM32C091CCT6
- Clock source: Internal HSI (48 MHz)
- SYSCLK: 48 MHz
- TIM14 clock: 48 MHz
- Prescaler: 47
- Timer resolution: 1 µs per tick
- Pulse window: 1,000,000 timer ticks (expected = 1000 ms)
Observation
When measuring the pulse window using a logic analyser, we consistently observe the following:
- Expected pulse window: 1000 ms
- Measured pulse window: ~995 ms
- Timing error: approximately 0.5%
This timing difference directly affects the pulse-per-second measurement used by downstream equipment.
Current Workaround
To compensate for the observed timing difference, we increased the pulse window by approximately 5000 ppm:
- Original window: 1,000,000 ticks
- Compensated window: 1,005,000 ticks
This produces a measured pulse window very close to 1000 ms.
Questions
- Is an observed timing error of approximately 0.5% expected when using the STM32C091 internal HSI oscillator?
- Does the factory calibration tolerance of the HSI explain this level of timing deviation?
- For applications requiring accurate pulse-per-second timing, what is the recommended approach?
- HSI trimming or calibration
- Runtime compensation
- Using an external HSE crystal/oscillator
- Another recommended method
- Is compensating the timer window (approximately +5000 ppm) an acceptable long-term solution, or is there a better approach recommended by ST?
We would appreciate your guidance on the recommended method for achieving accurate timer-based pulse generation using the STM32C091 series.
Thank you.
