cancel
Showing results for 
Search instead for 
Did you mean: 

No DMA Callback in I2S DMA Half Duplex Transit

95lux
Associate

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

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Chief II

(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 "Accept as Solution".

View solution in original post

2 REPLIES 2
AScha.3
Chief II

(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 "Accept as Solution".

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.