2025-01-22 01: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?
2025-01-22 01:29 AM - edited 2025-01-22 01: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.