cancel
Showing results for 
Search instead for 
Did you mean: 

Is Full Duplex Possible with DMA and how to use it with CubeMX

RBoel
Associate

Hello there,

up to now i have used an Audio DAC on a STM32F407 with DMA and Half/Full Transfer Interrupts with CubeMX. So far so good.

But now i am a little bit confused.

As i have read some Posts it seems that it might be not possible to use Full Duplex with DMA. Is that correct or not ?

I have tested a little bit around with the function "HAL_I2SEx_TransmitReceive_DMA" and after i little bit of debugging i am confused why the Function "I2SEx_TxRxDMACplt", the DMA Handler runs finally into, directly says : "if DMA is not in circular mode" as stated in the Source Code of the stm32f4xx_hal_i2s.c"

Do you have any hint why the circular Mode seems to be not supported when in Full Duplex Mode ? Does it mean that Full Duplex is not possible in Circular mode ?

Or is there something small that i have to take care of to use this Mode (preferred in DMA with Circular buffering) ?

3 REPLIES 3

There is no inherent bound between DMA's Circular/nonCircular mode, and I2S being duplex or not. In fact, DMA's hardware is complete agnostic of other modules - it sees some trigger and then moves data from source pointer to destination pointer; and it does not care about where the trigger comes from and where do the pointers point (except for the peripheral pointer in DMA1, which has to be within the constraints of APB1's address space, but that's not important here). For this particular case this means, that if you can use DMA with fullduplex I2S in non-circular mode, there's nothing what would prevent it to be used in Circular mode.

In other words, that comment relates purely to the particular code in Cube. Now I don't and won't use Cube, but from casual reading of the mentioned function I'd say the above comment is supposed to say something like "if this function is called when DMA is in non-circular mode, disable respective DMA-enable bits in the respective SPI modules and call callback; otherwise (in circular mode) do nothing".

JW

RBoel
Associate

Ok, so in principle it is possible to use I2S Full Duplex with DMA in Circular Mode ?

But might it be that the HAL doesn't support this configuration or might there be a bug in it ?

As i have debugged it seems that the call of HAL_I2SEx_TransmitReceive_DMA doesn't install the callback for "Half Transfer complete", and in further Progress, the DMA Initialization doesn't set the Half Complete Transfer Flag, so the DMA Interrupt only is called when transfer is complete. But even without the Half transfer callback, as long as the DMA_SxCR_CIRC bit is set, the function I2SEx_TxRxDMACplt doesn't do anything, because there is simply no else-branch so that this functionality seems to be not implemented. Is that right ?

Or maybe it was the intention of Cube's authors, not to enable the half-complete flag and not to call the callback.

Cube's "logic" is impenetrable for me, that's why I don't and won't use it. I like to own my software.

YMMV

JW