Page 1 of 1
STM32 noob needs help with STM32H523V project
Posted: Wed Jul 02, 2025 4:28 pm
by memotronics
Hi all,
I'm new to the STM32, I'm more of an 8-bit AVR guy and now I've grown up and want to play with the big boys.
My project requires a lot of I/O, so I landed on the STM32H523VE. I'm developing in the Arduino IDE, and I think I've managed to get the IDE set up, more or less. I'm not using any pre-made boards. For now, I'm talking directly to the MCU.
I need some help getting a better understanding of how to deal with certain I/O requirements, because the AVRs that I'm used to don't have support for those on the MCU, instead I'm used to having external ICs manage those, connected via SPI, I2C or parallel.
Here's what I need to talk to:
- SD-Card
- USB Keyboard (so STM32 acts as USB Host)
and my questions are:
- For SD, should I just use SPI or should I use the built-into-the-MCU SD-card support ?
- For the built-in USB, how would I go about it (library-wise and code-wise) ?
Also, unrelated to I/O: When running at full speed (250 MHz), is the interrupt overhead for a GPIO-initiated interrupt known? By that, I mean: How much time passes between the time that there's a signal transition on the pin until my interrupt-attached code starts executing? And when my interrupt-attached code finishes, how much time-overhead is there on the tail end?
Thanks !
JE
Re: STM32 noob needs help with STM32H523V project
Posted: Wed Jul 02, 2025 8:59 pm
by ozcar
memotronics wrote: Wed Jul 02, 2025 4:28 pm
...
Also, unrelated to I/O: When running at full speed (250 MHz), is the interrupt overhead for a GPIO-initiated interrupt known? By that, I mean: How much time passes between the time that there's a signal transition on the pin until my interrupt-attached code starts executing? And when my interrupt-attached code finishes, how much time-overhead is there on the tail end?
Thanks !
JE
There is probably a fair bit of overhead in the Stm32duino and HAL code.
If you have a DSO you could toggle a spare GPIO in the interrupt routine. I have also done what I call the "out to lunch test", where I also get the mainline code to spin doing nothing other than flip another GPIO. EG as at
viewtopic.php?p=2562&sid=c6ea9100e61396 ... e11a#p2562 .
I don't have a H523 to try that on though. I do have a couple of H503 boards but have not done something like that on one of those.
Re: STM32 noob needs help with STM32H523V project
Posted: Thu Jul 03, 2025 5:23 am
by ag123
stm32h5 series is fairly new
the STM 'official' core (implementation) is one that supports them
https://github.com/stm32duino/Arduino_C ... 2h5-boards
https://github.com/stm32duino/Arduino_Core_STM32/wiki
https://github.com/stm32duino/Arduino_C ... ng-Started
you may need to add a variant for your board
https://github.com/stm32duino/Arduino_C ... 28board%29
there is a SD library here, but that I've not used it
https://github.com/stm32duino/STM32SD
alternatives are like SdFat, it uses SPI
https://github.com/greiman/SdFat
for now SPI is 'slow' due to DMA not being used
there are some untested SPI DMA codes here, I've not tested them and I'm not sure if it'd work.
viewtopic.php?p=15283#p15283
currently, USB is supported out of the core in *device* mode. USB host is not.
there are various usb classes supported, usb (CDC) serial (virtual comm port) is one of them.
if you need usb (CDC) serial (virtual comm port) to your serial monitor (terminal), simply select that as Serial from the (Arduino IDE) menu when you build your sketch. I think there is also hid (keyboard) device.
if you need USB host, you may need to review and use the original usb libraries from STM for Cube IDE, Cube MX , HAL etc
https://wiki.st.com/stm32mcu/wiki/Intro ... with_STM32
https://wiki.st.com/stm32mcu/wiki/Intro ... y_overview
that library is apparently bundled in the core
https://github.com/stm32duino/Arduino_C ... lewares/ST
but that you would need to figure out how to use it.
playing with SD and USB especially host is somewhat "jumping into the deep end" if you are a beginner.
Re: STM32 noob needs help with STM32H523V project
Posted: Thu Jul 03, 2025 7:01 am
by ag123
if what is needed is a keyboard, there are some alternatives e.g. ps/2 keyboard
https://en.wikipedia.org/wiki/PS/2_port
https://www.aliexpress.com/w/wholesale- ... board.html
https://www.burtonsys.com/ps2_chapweske.htm
https://oe7twj.at/images/6/6a/PS2_Keyboard.pdf
https://github.com/PaulStoffregen/PS2Keyboard
it'd seem like stm32's u(s)art can handle it, but that I'm not sure and you may need to find or make a driver to handle the key scancodes
https://github.com/gandro/stm32-ps2
https://github.com/RobertoBenjami/stm32_ps2
these seemed to emulate the keyboard itself rather than the host
attaching a keyboard to stm32 playing the host is an interesting idea
but that for usb host, that needs to be implemented manually (linking the usb host library)
https://wiki.st.com/stm32mcu/wiki/Intro ... y_overview
and that the board needs to supply usb power and implement usb OTG
https://en.wikipedia.org/wiki/USB_On-The-Go
this should be a feasible option as well, just that I've not done it (yet)
I think stm32 h5xx in some sense can practically run as a full host (instead of device), e.g. as like a PC with an OS
e.g. stm32h562 can have like 640 k (sram), that is the 'grand old' number for old IBM PC XT/ATs running msdos !
and this is *much* faster
https://www.st.com/en/microcontrollers- ... eries.html
what is more interesting, is the support for Octo-SPI interface
https://www.st.com/resource/en/datashee ... h562rg.pdf
in which you can practically add SPI PS RAM possibly extending that to megabytes to even gigabytes
https://www.st.com/en/partner-products- ... psram.html
https://www.avalanche-technology.com/do ... am-memory/
for a buy-off-the shelf stm32h562 board, WeAct has one
https://github.com/WeActStudio/WeActStu ... _CoreBoard
https://www.aliexpress.com/item/1005007502799023.html
and is directly supported in the core
https://github.com/stm32duino/Arduino_C ... 2h5-boards
Re: STM32 noob needs help with STM32H523V project
Posted: Thu Jul 03, 2025 7:34 am
by ag123
oh about those interrupts and hardware etc stuff
note that STM32 has verbose very detailed well written reference manuals
https://www.st.com/resource/en/referenc ... ronics.pdf
as well as review the specs documents
https://www.st.com/resource/en/datashee ... h523ce.pdf
^ there is figure 1 block diagram which is quite informative
what is quite interesting is that STM32 H5 APB (peripheral buses ) is capable of running at 250 Mhz
I'm not too sure if the GPIO itself can be clocked that fast, but I'd think that would be covered in the ref manual or spec sheets
EXTI (external interrupts) ISR normally can't run too fast, usually has some limits say like (well) below 1 mhz. code latencies etc.
one thing to learn and understand stm32 is to review the "reset and clock control" chapter 11
https://www.st.com/resource/en/referenc ... ronics.pdf
and the various chapters e.g. GPIO, EXTI etc as relevant