Skip to main content
Visitor II
May 8, 2025
Question

I2S Full Duplex with STM32F301

  • May 8, 2025
  • 3 replies
  • 781 views

Hello,

I try to use I2S in full duplex mode master with DMA but it doesn't work as expected.

The I2S is configured in 24 bits @32Khz.

DMA TX and RX are configured in half-word circular mode.

I can send data manually but if I loop the input to the output using software, nothing comes out even though there is data on PB4.

DMAs are started with :

HAL_I2S_Transmit_DMA(&hi2s3, I2S_DAC_Buffer, 2);
HAL_I2S_Receive_DMA( &hi2s3, I2S_ADC_Buffer, 2);

I used the function HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) in main.c like this :

void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
{
I2S_DAC_Buffer[0] = I2S_ADC_Buffer[0];
I2S_DAC_Buffer[1] = I2S_ADC_Buffer[1];
I2S_DAC_Buffer[2] = I2S_ADC_Buffer[2];
I2S_DAC_Buffer[3] = I2S_ADC_Buffer[3];
}

I checked by flashing an LED, the callback function is called as it should.

Why doesn't it work?

I can provide other parts of the code if needed.

    This topic has been closed for replies.

    3 replies

    Super User
    May 8, 2025

    I2S is either a transmitter, or a receiver. It is never both. You have it set as a master transmitter. It cannot receive.

    TDK_0-1746736943479.png

     

    MafoAuthor
    Visitor II
    May 8, 2025

    RM0313 is for STM32F37xxx

    RM0366 is for STM32F301.

    Why is there a difference between half and full duplex if we can't transmit and receive at the same time?

    Super User
    May 8, 2025

    You can use the I2S master transmit + receive, but it happens same time, so you have to use:

    HAL_I2SEx_TransmitReceive_DMA(...) .

    In callbacks feed the send buffer + read the input buffer, then it will work.

     

    from rm 0316,  F303:

    AScha3_0-1746738607779.png

    ed

    Oh, i just see : F301 . :)    So use F303 , to have full duplex.

    MafoAuthor
    Visitor II
    May 9, 2025

    With F301 and the use of function I2SEx : 

    HAL_I2SEx_TransmitReceive_DMA( &hi2s3, I2S_DAC_Buffer, I2S_ADC_Buffer, 2);

    HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s)

    it works very well in full duplex mode.

    Thank you for your help.