cancel
Showing results for 
Search instead for 
Did you mean: 

I2S Full Duplex with STM32F301

Mafo
Visitor

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.

3 REPLIES 3
TDK
Guru

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

 

If you feel a post has answered your question, please click "Accept as Solution".
Mafo
Visitor

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?

AScha.3
Chief III

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.

If you feel a post has answered your question, please click "Accept as Solution".