Skip to main content
Associate II
May 8, 2024
Solved

No DMA Callback in I2S DMA Half Duplex Transit

I am using a Nucleo F401RE board to drive a PCM5102a PCM Audio Codec via I2S.

My goal is to send data from a double buffer via DMA.

Since I am only using the Audio Codec as an output, I configured my I2S as Half-Duplex Master in CubeMX.

Now to my problem:

In the generated I2S HAL driver stm32f4xx_hal_i2s_ex.c, there is no DMA Callback registered for Transmit Cplt or HalfCplt:

I am calling HAL_I2SEx_TransmitReceive_DMA in main.c, to start the DMA cycle. everything works fine, except Callback invocation. Here is the corresponding snippet in the generated HAL_I2SEx_TransmitReceive_DMA, that prevents Tx Callbacks.

/* Set the I2S Rx DMA Half transfer complete callback */
hi2s->hdmarx->XferHalfCpltCallback = I2SEx_TxRxDMAHalfCplt;

/* Set the I2S Rx DMA transfer complete callback */
hi2s->hdmarx->XferCpltCallback = I2SEx_TxRxDMACplt;

/* Set the I2S Rx DMA error callback */
hi2s->hdmarx->XferErrorCallback = I2SEx_TxRxDMAError;

/* Set the I2S Tx DMA Half transfer complete callback as NULL */
hi2s->hdmatx->XferHalfCpltCallback = NULL;

/* Set the I2S Tx DMA transfer complete callback as NULL */
hi2s->hdmatx->XferCpltCallback = NULL;

This of course makes sense when using DMA RxTx at the same time so that the Callbacks only trigger once per RxTx/RxTxHalf. But since I set I2S to Transmit only (Half-Duplex), the callbacks won't fire at all.

Is this expected behavior?

Best, jonas

 

 

 

 

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
May 8, 2024

(I have used the F401 to play audio - working fine, as long as using standard I2S with 16bit data.)

How you set the chip ? with Cube/HAL ? (I did ; works as expected.)

To get the callbacks (+ yes, only for Tx , with circular DMA ) set in Cube : Callback enable I2S ...see:

AScha3_0-1715159917572.png

 

If you feel a post has answered your question, please click on " Best Answer ".

2 replies

AScha.3
AScha.3Best answer
Super User
May 8, 2024

(I have used the F401 to play audio - working fine, as long as using standard I2S with 16bit data.)

How you set the chip ? with Cube/HAL ? (I did ; works as expected.)

To get the callbacks (+ yes, only for Tx , with circular DMA ) set in Cube : Callback enable I2S ...see:

AScha3_0-1715159917572.png

 

If you feel a post has answered your question, please click on " Best Answer ".
95luxAuthor
Associate II
May 8, 2024

Thanks a lot, i forgot to register the i2s Callbacks. Since the DMA Callbacks are automatically registered for RxTx, i would't think of registering i2s Callbacks seperately.