STM32H745 input fast read
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-22 1:04 AM
Hi, I have problem. I have idea: my STM32H745 must read GPIO state as quickly as possible. FCPU = ~400MHz
I wrote the program in assembler for M7
LED_ON()
ldr r2, [r3, #IDR]
ldr r2, [r3, #IDR]
... ~650x
LED_OFF()
...
only read, IDR, no write (no record yet)
And when I measure with an oscilloscope the led output is on for 25us -> one LDR 15 cycles clock CPU. When I read from RAM it takes about 12us, but GPIO 25us.
This is too slow for me. I tried all the tricks and combinations of LDR; STR ... LDR LDR STR STR ... LDR AND LDR STR AND ... Minimum is 25us.
LDR gpio and STR ram are without comment at all. Some astronomical values ​​come out that can be obtained from AVR or DSPIC.
I tried FMC to read and it was even worse.
What is the fastest way to read the state of a ~40MHz pin?
Solved! Go to Solution.
- Labels:
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-22 1:29 AM - edited ‎2025-01-22 1:30 AM
Two possibilities:
- For single pin - use SPI MISO line and SPI RX DMA. This guarantees fixed sampling frequency.
- For multiple pins - use timer-triggered DMA from port to memory. Some frequency variations and jitter will appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-22 1:29 AM - edited ‎2025-01-22 1:30 AM
Two possibilities:
- For single pin - use SPI MISO line and SPI RX DMA. This guarantees fixed sampling frequency.
- For multiple pins - use timer-triggered DMA from port to memory. Some frequency variations and jitter will appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-30 11:22 AM
Ok works. It's a pity that it can't be done differently. Creating a 30-40MHz real-time system with non-standard pin analysis is practically impossible with ARM :(. Too large a range of possible problems. My system worked somehow, but it was supposed to be very easy, but it was very confusing and I probably won't come up with such an idea again :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-30 12:14 PM
If you talk about the direct r/w to a port/pin, its not "ARM" making it fast or slow - its how the SOC is built and connected to the core.
So on H7 you more on a "PC" , fast core and calculations, but gpio is "far away" from the core, going over some bus connections to reach a port.
If you want direct r/w to a port/pin fast, look at the M33-core series, maybe stm32H563 .
Here ports are on direct connection to core, so you get : (in my tests)
(speed test, option -O2 , at 250MHz core ) bsrr 4ns ; so port access here 1 cyc, 4 ns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-31 12:41 AM
I'll try it sometime.
I saw that it's a long way from the core to GPIO, but I didn't think it was that far :). And the documentation doesn't have many details about it, so it just came out that way.
