cancel
Showing results for 
Search instead for 
Did you mean: 

STM32M4 (TX) transmits i2s data to another STM32M4 (RX) fails

JuliusChen
Visitor

I am trying to use one STM32M4 as TX, and another STM32M4 as RX,

but RX can't receive the correct i2s data that TX transmits.

TX transmits 16bits data by HAL_I2S_Transmit_IT(&hi2s2, i2s_dummy_buffer, 16);

RX receives 16bits data by HAL_I2S_Receive_DMA(&hi2s2, i2s_received_buffer, 16);

 

The results:

1) If TX transmit 0,1,2,...,15:

RX receives:

[0] = 0xC000 [1] = 0x0000 [2] = 0x4000 [3] = 0x8000

[4] = 0xC001 [5] = 0x0001 [6] = 0x4001 [7] = 0x8001

[8] = 0xC002 [9] = 0x0002 [10]= 0x4002 [11]= 0x8002

[12]= 0xC003 [13]= 0x0003 [14]= 0x4003 [15]= 0x8003

2) If TX transmits 16bits  of 0xAAAA

RX receives 16bits of 0xAAAA

3) If TX transmits a sin wave

RX receives 16bits of unknown number

 

The following is TX and RX's config:

TX:

JuliusChen_0-1761197501348.png

JuliusChen_1-1761197527804.png

RX:

JuliusChen_2-1761197568551.png

JuliusChen_3-1761197591296.png

Let me know if you need more information,

thanks!!!

 

 

3 REPLIES 3
AScha.3
Super User

Which cpu is STM32M4 ?

+

As I2S is a kind of SPI and you seem to set the rx and tx I2S correct - you put some wrong data to the tx array, 

or dma reads on wrong address ..etc.

But fundamentally I2S is for continuous running streams, not just put some number in , to test it.

So start the rx and then tx with circular DMA on both and in callbacks put in data to tx arrays, or zero, to "pause",

but never stop it. And it will work, as it should.

(I made some audio players...so i know. :) )

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

Hello @JuliusChen and welcome to the community;

 

Could you please give more details about the issue? How to write your question to maximize your chance... - STMicroelectronics Community

Please try to transmit data with DMA mode. Are you facing the same issue?

 

Thank you.

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

TDK
Super User

Looks like HAL_I2S_Transmit_IT is not keeping up with the needed data. Use HAL_I2S_Transmit_DMA instead.

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