STM32H562: adding support for UART11/UART12 #18477
Unanswered
daleka
asked this question in
STM32 / Pyboard
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm working with a board based on STM32H562 (STM32H562VGT6, 12 hardware UARTs) and the STM32 port of MicroPython.
As far as I can see, the current STM32 port of MicroPython only has 10 UARTs described. But my board actually has 12 hardware UARTs, and I need to use UART11 (and later possibly UART12 as well). I tried to add UART11 support myself: the firmware builds and runs, but at baud rates higher than 9600 I start losing bits / getting corrupted data on UART11. At 9600 baud everything looks stable.
So I suspect that my changes are incomplete or incorrect somewhere (clocks, IRQs, array sizes, instance mapping, etc.).
What I changed
Base setup:
MicroPython: v1.26.1 (stm32 port, master at the time of work)
Board: custom, starting from boards/WEACT_H562RG as a reference.
In boards/WEACT_H562RG/mpconfigboard.h I added:
#define MICROPY_HW_UART11_TX (pin_A6) – DDCMP/DEX interface
#define MICROPY_HW_UART11_RX (pin_A7) – DDCMP/DEX interface
And set:
#define MICROPY_HW_MAX_UART (12)
This macro is now defined only in one place to avoid the previous “redefined” warning/error.
I added the corresponding AF entries for PA6/PA7 (UART11_TX / UART11_RX) in pins.csv, so that I can create machine.UART(11, ...) from MicroPython.
In uart.c and uart.h (STM32 port) I found the places where only 10 UARTs were listed and extended them to 11:
added the instance/handle description for UART11;
updated arrays/tables that list UARTs (handles, base addresses, numbers, etc.) to include UART11;
made sure the indexing matches UART number 11 and is not limited by the previous maximum of 10.
In stm32_it.c I added an interrupt handler for UART11, similar to the other UARTs:
defined the IRQ handler for UART11;
called the corresponding HAL/MicroPython function inside this IRQ.
After these changes the firmware successfully builds, flashes.
The problem
At 9600 baud data looks correct, I don't see obvious errors or losses.
At 19200 baud and higher I see lost bits / corrupted bytes.
It looks like either UART11 is not fully configured correctly at the low level, or the STM32 port of MicroPython is not fully prepared for UART indices > 10 (array sizes, IRQ tables, constants, buffers, or some other hidden limit).
The hardware itself should be OK: short cable, clean signal, other UARTs on the same board work at 19200 just fine.
What I'm looking for
Before I dig too deeply into the STM32 port internals, I wanted to ask the community:
Has anyone already used UART11 or UART12 on any STM32 board with MicroPython (H5/H7 or similar)?
If yes, I would really appreciate if you could share:
snippets from mpconfigboard.h with MICROPY_HW_UARTxx_*;
changes in uart.c / uart.h / stm32_it.c (or any other files where UART instances, tables, and IRQs are described);
pins.csv entries for these UARTs.
Is there any known limitation that MICROPY_HW_MAX_UART should not exceed 10 in the current STM32 port?
Or should it work fine with 12, as long as all tables/arrays and IRQs are correctly updated?
If someone already has a working board definition where UART11/12 run at higher baud rates (19200+ baud) without data loss, I'd be very grateful for example files or a small patch. That would make it much easier to compare with my changes and see where the mistake is.
Thanks in advance for any hints or example configs. If needed, I can upload the full mpconfigboard.h / pins.csv / diffs of my changes.
Beta Was this translation helpful? Give feedback.
All reactions