2025-06-22 10:05 PM - last edited on 2025-06-23 4:29 AM by Andrew Neil
Hi,
I want to get data from an ADC connected externally through SPI DMA whenever data ready pin is set.
I want to do it without any interrupt handler, since our firmware have already loaded with other stuffs.
I have tried the synchronisation of SPI DMA with GPIO EXTI trigger. It works when I configure SPI DMA in circular mode only.
Because synchronisation doesn't triggers the SPI DMA it just syncs the process. I can't find any options to trigger the SPI DMA with timer or any event.
How to trigger SPI DMA through GPIO EXTI event? Is that possible in STM32G4 series?.
Thank you!
2025-06-22 11:37 PM
There are multiple ways:
Better one: use DMAMUX and its synchronisation feature. Look at figure 33 in Reference Manual. Use EXTI line from your GPIO to "trigger" (synchronise) SPI TX DMA requests.
Alternative one: Route your signal to timer input. Set timer to trigger by external event and to one-shot mode. Use timer DMA request to trigger transfer data to SPI. Timer is in this case used only to "route" signal from GPIO as DMA request.
Of course in both cases use DMA for SPI reading (read is triggered by write...)
https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
2025-06-22 11:42 PM
@BrindhaP wrote:
Because synchronisation doesn't triggers the SPI DMA it just syncs the process. I can't find any options to trigger the SPI DMA with timer or any event.
You probably misunderstand synchronisation.
Usualy you enable SPI TX DMA request, they are blocked by synchronisation feature in DMAMUX. When synchronisation event comes, then waiting requests pass on to DMA. In other words, DMA request are generated by SPI, DMAMUX only hold them until synchronisation event comes.
BTW: If needed (which is not the case), request also can be generated by DMAMUX - "request generator" feature.
2025-06-23 12:33 AM
Thank you for the reply.
How to use DMA request generator to generate DMA RX/TX ?
2025-06-23 1:14 AM
@BrindhaP wrote:How to use DMA request generator to generate DMA RX/TX ?
Eh, Reference Manual specify that in 13.4.5. But generaly it is not good idea to sending data to SPI this way. Why ? DMA request generator dont care about SPI buffer status and writes data to it even if there is no room which may lead to data loss.
If i understand your problem correct, then you should set SPI TX to generate DMA requests and synchronize them by synchronization feature.