Finally got some time to chase the loose thread on timing issues, and the motor bringup resurfaced the issue.
Quick recap from the jitter post: the 1 kHz control tick on my pan tracker met its p99 target, but the Saleae and the DWT cycle counter didn’t agree, and the tick rate moved between captures (+2,398 ppm in one, +2,895 ppm in the next). My guess was the board clock, and it went on the todo list.
Background
- HSE
- High-speed external clock. The STM32’s input for an outside clock source, usually a crystal.
- HSI
- High-speed internal clock. An RC oscillator inside the chip. Convenient, but it drifts with temperature and isn’t anywhere near crystal accuracy.
- Bypass mode
- HSE takes a ready-made clock signal on its input pin instead of driving a crystal.
- MCO
- Microcontroller clock output. A pin that outputs one of the chip’s internal clocks, optionally divided down.
- PLL (M, N, P, Q)
- Multiplies the input clock up to the system clock. M divides the input, N multiplies it, and P and Q divide the result for the outputs. Here P feeds SYSCLK and Q feeds FDCAN.
- ppm
- Parts per million. +4,306 ppm is 0.43% fast, or about 4.3 ms gained every second.
The motor PWM was off too
During motor bring-up I logged the PWM pin on the Saleae. With TIM1 set up for exactly 20.000 kHz (8 MHz HSE in bypass, PLL1 M 1, N 65, P 1), the Saleae read 20.073 kHz in one capture and 20.101 kHz in another…
This was the same symptom as the tick. So it seemed that either the board was fast or the Saleae was slow, and the captures alone couldn’t disambiguate that.
Board vs. laptop
To settle it I had Claude write tools/clock_drift.py. Every 10 s it notes the laptop time, sends uptime over the Nucleo CLI (via pyserial), and notes the time again when the prompt comes back. At the end of the run, the Nucleo’s clock is compared against the laptop’s (which is Network Time Protocol disciplined). A straight-line fit over all the samples gives the rate error in ppm. With the laptop as the reference, a 5-minute run resolves to ~15 ppm.
The board gained 1.29 s in 5 minutes: +4,306 ppm, wandering between about +4,050 and +4,430 ppm during the run.

Boom: the Saleae was accurate after all (of course), and the board’s clock was confirmed to be running fast!
Where the 8 MHz comes from
The STM32CubeMX system configuration tool has a nice visualization of the clock tree, and allows you to tweak it directly in the GUI. What it doesn’t show is that on the NUCLEO-H723ZG, HSE is sourced from the ST-LINK’s MCO output in bypass mode… which is a whole ass other chip on the board (ref: UM2407, section 7.5.1). By default the STLINK-V3 outputs 8 MHz from its own STM32F723’s HSI divided by 2.
tl;dr: the “HSE” on my clock tree was really a crappy RC oscillator coming from a different chip altogether!
Bad news. While the tick and the PWM can live with that just fine, CAN is where it matters. At 1 Mbps the Nucleo and the Jetson have to agree on bit timing, and all of this error on the Nucleo side could cause issues down the line, especially given RC oscillators are susceptible to temperature-based drift. Motors hot. Drift bad.
The fix
Luckily, the ST-LINK firmware V3J7M2 and later can output HSE/3 (8.333 MHz) or HSE/5 (5 MHz) from the ST-LINK’s 25 MHz crystal instead!
Steps to resolve:
- Updated the ST-LINK with STLinkUpgrade 3.17.11 (from the VS Code STM32 bundles) and picked MCO = HSE/5.
- CubeMX: HSE input 5 MHz in bypass,
HSE_VALUE5000000. - PLL1 M 1, N 104, P 1, Q 4 to keep 520 MHz SYSCLK and 130 MHz for FDCAN.
- PLL2 M 1, N 96, P 5 for the 96 MHz ADC clock
- Bus and timer clocks remained unchanged
| HSE source | PLL1 | Board vs. laptop | |
|---|---|---|---|
| Before | ST-LINK HSI/2, 8 MHz (RC) | M 1, N 65, P 1 | +4,306 ppm |
| After | ST-LINK HSE/5, 5 MHz (crystal) | M 1, N 104, P 1 | +5 ppm |
+5 ppm over 300 s, inside the script’s ~15 ppm resolution.
Fix the clock issue? CAN do. … sorry.
Back to the jitter
With the clock on the crystal, I reran the same two 90 s Saleae captures on PG14 (100 MS/s, I-cache on, TIM6 at priority 4).

| Capture | Clock | Rate | Std dev | p99 | Max |
|---|---|---|---|---|---|
| Idle | ST-LINK RC (Nov 5) | +2,398 ppm | 444 ns | 1,112 ns | 1,822 ns |
| Loaded | ST-LINK RC (Nov 5) | +2,895 ppm | 443 ns | 1,115 ns | 1,825 ns |
| Idle | ST-LINK crystal (Nov 18) | +3 ppm | 33 ns | 77 ns | 77 ns |
| Loaded | ST-LINK crystal (Nov 18) | +4 ppm | 15 ns | 34 ns | 36 ns |
p99 went from 1.1 µs to 77 ns idle and 34 ns loaded! Hooray! It’s clear that the flat ±1.1 µs spread seen before was the ST-LINK’s RC oscillator wandering, not the tick.
Both new numbers fall within a few Saleae samples (10 ns at 100 MS/s), so the Saleae can’t reliably pick up the tick’s jitter anymore. The DWT min/max (±153 ns idle, ±119 ns loaded) is the better number now: one tick a little late, the next one a little early. Loading still basically makes no difference, which is what you’d expect with TIM6 above the FreeRTOS mask! Sanity restored.