cancel
Showing results for 
Search instead for 
Did you mean: 

Problems: STM32H743ZI two SPIs to receive data with DMA

MSun.5
Associate II

Hello,

I use STM32H743ZI two SPIs with DMA to collect data. The data are OK when only one SPI with DMA is activated. However, when I use two SPIs with DMA to collect data simultaneously, the data collected are not correct.

The DMA setup:0690X000006C7kIQAS.pngCodes to collect data using SPI with DMA:0690X000006C7kNQAS.png0690X000006C7kSQAS.pngI use SPIs with DMA to collect a triangular signal (16 bit) at ~600KSPS, and save and transfer the data to data[]. If I only use SPI2 with DMA, the collection data[] is,0690X000006C7kXQAS.png0690X000006C7kcQAC.pngThe collection is good.

If I only use SPI3 with DMA, the collection data[] is,0690X000006C7khQAC.png0690X000006C7kmQAC.pngThe collection is good.

However, if I use both SPI2 with DMA and SPI3 with DMA to collect the signal simultaneously, the collection data[] is,0690X000006C7krQAC.png0690X000006C7kdQAC.png

The collections from both SPI2 and SPI3 are distorted.

4 REPLIES 4
T J
Lead

what is the SPI slave ?

there are 2 slaves on 1 SPI bus ?

how do you account for the nSS pins ? .. there should be two nSS pins

as far as I know, in the older ST processors the automatic nSS functionality didn't work.

certainly not with DMA. maybe it is resolved on the H7.

anyhow, nSS pins, how do you address that ?

AvaTar
Lead

Not doing HAL, but looks like two different SPI units, with different DMA channels.

The HAL/Cube code, I think, is quite pathetic in handling concurrency.

I suppose one channel blocks out handling of the receive data for the second channel long enough that the next data overwrite the current one.

> I suppose one channel blocks out handling of the receive data for the second channel l

That isn't very feasible unless the SPIs run at extreme rates, and even then I'm not quite sure this could happen with two SPI/DMAs only.

Can't see more through the haze in my crystall ball.

JW

AvaTar
Lead

> That isn't very feasible unless the SPIs run at extreme rates, and even then I'm not quite sure this could happen with two SPI/DMAs only.

Not much overlap required for occasional data corruption. Or perhaps two external devices triggered at the same time.

[OP] > I use STM32H743ZI two SPIs with DMA to collect data.

I would have used one SPI interface, and manually managed NSS signals.

> Can't see more through the haze in my crystall ball.

I very much agree.