cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745 input fast read

EsKi
Associate

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Lead III

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.

 

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

View solution in original post

3 REPLIES 3
gbm
Lead III

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.

 

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
EsKi
Associate

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 :)

 

In my life I've written a lot in various assemblers x86, PIC, DSPIC, AVR, Z80, even 6502 and a bit MC68000. I thought that ARM, popular in the 21st century, and a large 400MHz clock would solve the problem, but here I had to figure it out :). Fortunately, it worked, but never again :).
 
 
 

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.

If you feel a post has answered your question, please click "Accept as Solution".