F0028 err-8¶
Rule: G0 ADC calibration waits two ADC clocks after the disable.
| Code | F0028 (stable, never reused) |
| Id | err-8 |
| Category | err |
| Source | spirit_level |
| Fix | by hand |
Level per tier¶
| Tier | Level | Reason |
|---|---|---|
| small | off | |
| small-workspace | off | |
| medium | off | |
| big | off | |
| ai | off | |
| embedded | warn |
bedrock warning: G0 ADC calibration without the wait of 2 ADC kernel clocks after disable (freezes) |
| ui | off | |
| egui | off | |
| units-strict | off | |
| units-paranoid | off |
Why¶
Efton.sk gotcha 221 ("ADC may freeze around calibration or enable/disable, sequencing has to be observed carefully"), the G0/C0/WL paragraph:
In 'G0 (and related 'C0 and 'WL families), there should be a 2 ADC kernel clock delay observed after disabling the ADC, and performing any other ADC-kernel-related operation (such as re-enabling ADC, or performing calibration, or writing the calibration factor).
The underlying cause (per the same page) is that the ADC is a dual-clock peripheral: the APB side the rest of the chip talks to and the kernel-clock side that actually runs the conversion need their signals resynchronized across the clock-domain boundary, and the timing of that resync depends on the exact ratio between the two clocks โ which is why the symptom (an ADC that freezes) is hard to reproduce and depends on the specific clock configuration in use.
Example¶
Typec_dongle's ADC calibration path (0.20.7) added exactly this wait after disabling the ADC and before the next kernel-related operation, closing a freeze that otherwise depended on the board's specific ADC clock divider to show up at all.
How to fix¶
After disabling the G0/C0/WL ADC, wait at least 2 ADC kernel clock periods before re-enabling it, starting calibration, or writing the calibration factor register โ compute the wait from the actual configured kernel clock, don't hardcode a microsecond figure that assumes one clock setting.
How it is checked¶
Check: src mid ยท chip: G0 โ needs the ADC kernel clock configuration to compute whether an observed delay between disable and the next operation is actually long enough.
Source¶
Ported from embedded_bedrock's firmware check catalogue, ERR-8 (book/checks.md, detail in book/checks/err.md). Found on: typec_dongle 0.20.7 (G0 gotcha 221).
Configure¶
Allow one finding in the code with // spirit-level: allow(err-8) <reason> (waivers); the code works there too, as in [lints.F0028].