← index #18934PR #16996
Related · high · value 2.633
QUERY · ISSUE

STM32 H563 I2C TIMINGR Add

openby vvchangningopened 2026-03-16updated 2026-03-16
enhancementport-stm32

Description

Description
The STM32H5 series (e.g., STM32H563/H573) features high-performance I2C peripherals (I2C V2 IP), which utilize the 32-bit I2C_TIMINGR register for baud rate and timing configuration (Standard-mode, Fast-mode, and Fast-mode Plus).

Currently, in ports/stm32/, the preprocessor logic for I2C_V2 and TIMINGR calculation includes families like STM32H7, STM32G0/G4, and STM32WB, but STM32H5 is notably absent. This prevents the driver from correctly initializing the I2C block on H5 hardware.

Verification & Results
I have implemented a patch to include STM32H5 in the I2C V2 logic. Local testing on a H563RI Board demonstrates that the timing calculation is accurate. I have successfully verified stable I2C communication at standard bus speeds, as well as custom configurations up to 1.5 MHz (overclocked Fast-mode Plus), which confirms the flexibility and correctness of the timing logic.

<img width="586" height="292" alt="Image" src="https://github.com/user-attachments/assets/e14a14fe-a3df-4fdb-9b7a-838631271579" />

Code Size

No response

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

ports/stm32/timer.c: Add support for STM32H5 Timer 1.

mergedby mattytrentiniopened 2025-03-23updated 2025-04-03
port-stm32

Summary

The STM32H5 build was lacking support for timer 1 (TIM1). The micro has hardware support for Timer 1 but MicroPython wasn't correctly configured to use it. Instead, when trying to construct the timer, a ValueError would occur:

>>> from pyb import Timer
>>> Timer(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Timer(1) doesn't exist

After integrating this PR:

>>> from pyb import Timer
>>> Timer(1)
Timer(1)

Testing

Tested PWM using Timer 1 on the Nucleo H563ZI.

All Timers appear to be instantiated correctly now:

=== from pyb import Timer
=== timers = []
=== for x in range(24):
===     try:
===         timers.append(Timer(x))
===     except ValueError as e:
===         print(e)
===
=== print(timers)
===
Timer(0) doesn't exist
Timer(9) doesn't exist
Timer(10) doesn't exist
Timer(11) doesn't exist
Timer(18) doesn't exist
Timer(19) doesn't exist
Timer(20) doesn't exist
Timer(21) doesn't exist
Timer(22) doesn't exist
Timer(23) doesn't exist
[Timer(1), Timer(2), Timer(3), Timer(4), Timer(5), Timer(6), Timer(7), Timer(8), Timer(12), Timer(13), Timer(14), Timer(15), Timer(16), Timer(17)]

Extra detail

The Datasheet's (DS14151 or DS14258 depending on the specific H5) show TIM1 as a 16bit advanced timer:

image

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied