2021-10-17 02:59 PM
I'm using an STM32H725 and am trying to read a block of SPI data (say, 100 samples) from an external SPI ADC on a fixed sampling schedule. That is, I do NOT want to read all 100 samples as fast as possible; I want to read 1 sample every microsecond.
I am trying to do this with DMA but it is not working. If I just use basic SPI+DMA it works...but it reads all 100 samples as fast as possible. As soon as I try to use DMAMUX triggers (request generator) or DMAMUX synchronization using TIM12_TRGO, things fall apart: I get overrun errors, or I get 10-11 readings and then it fails, and in all cases, the request generator or synchronizer is ignored: it still reads the SPI peripheral as fast as possible (instead of once per microsecond, as configured in TIM12).
Does anyone have any tips, suggestions, sample code that uses SPI Rx-only with DMA and timer-based trigger and/or synchronizer?
2021-10-17 03:14 PM
In case of SPI Rx, DMA is "consumer", i.e. you'd need to throttle SPI not DMA.
Probably the easiest way is to use fullduplex SPI (you don't need to assign a physical pin to MOSI in GPIO), use a second DMA triggered from the timer to transfer any random frame from memory to SPI's Tx data register, that will generate the clocks and thus SPI's Rx, which would then be transferred by its DMA to memory.
This is how I would do this in "normal" STM32s. The 'H7 SPI is overcomplicated, maybe there's some other way how to pull this out there.
JW
2021-10-17 07:46 PM
Most monodirection spi ip generations have non stop clock SCK generation hence incompatible with a dmamux wait function. As said Jan, use bidir communication without assigning Mosi, although you need to transmit to nowhere to generate clocks....