I2C Timing & Pull-Up Calculator
embedcalc_i2c_timingCompute I2C pull-up resistor range, verify SCL high/low timing margins, and estimate STM32 TIMINGR register from bus parameters.
Instructions
Compute I2C pull-up resistor range (Rp min from sink current, Rp max from rise time vs bus capacitance), SCL high/low budget, and an STM32 I2C TIMINGR register estimate.
Args:
mode: 'ls' (10k), 'sm' (100k), 'fm' (400k), 'fmp' (1M, 20mA sink), 'hs' (3.4M).
vdd (V, default 3.3), bus_capacitance_pf (default 100).
stm32_clock_mhz (default 16): I2CCLK kernel clock for the TIMINGR estimate.
Returns (structured): rp_min_ohm / rp_max_ohm, scl high/low vs spec minimums, rise/fall limits, stm32 { presc, scll, sclh, sdadel, scldel, timingr_hex }. The TIMINGR value is an estimate per RM formulas — verify on scope for production. Example: Fast-mode, 3.3V, 100pF -> Rp between ~967Ω and ~3.5kΩ (use 2.2k).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vdd | No | Bus supply voltage in volts | |
| mode | No | Bus speed mode: ls=10kHz, sm=100kHz, fm=400kHz, fmp=1MHz, hs=3.4MHz | sm |
| stm32_clock_mhz | No | STM32 I2C kernel clock (I2CCLK) in MHz for TIMINGR estimate | |
| bus_capacitance_pf | No | Total bus capacitance in pF (spec max 400 pF) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stm32 | Yes | ||
| rp_max_ohm | Yes | ||
| rp_min_ohm | Yes | ||
| scl_low_us | Yes | ||
| scl_high_us | Yes | ||
| t_fall_max_ns | Yes | ||
| t_rise_max_ns | Yes | ||
| target_freq_hz | Yes | ||
| scl_low_min_spec_us | Yes | ||
| scl_high_min_spec_us | Yes |