cancel
Showing results for 
Search instead for 
Did you mean: 

Hello : I want to ask a question, how to use one I2S protocol in full duplex mode

mick
Associate II

 I work on project from a few days
I want to connect two audio codec with STM32H745
to receive data from first one and then processes it , and then transmit it to the second one and versus versa.
how to implement a part of code to organize exchange data in two direction TX and RX.
best regards

1 ACCEPTED SOLUTION

Accepted Solutions
Issamos
Lead II

Hello @mick  

Here are a few tips to implement bidirectional audio data exchange between two audio codecs with an STM32H745:

 

- Configure I2S or SPI peripherals for communication with each codec. 

 

- Use circular buffers (ring buffers) to store received and transmit data. One buffer for each direction.

 

- In I2S/SPI RX interrupts, store received data into the corresponding RX buffer.

 

- In I2S/SPI TX interrupts, send data from the corresponding TX buffer. 

 

- In the main loop:

  - Read data from codec 1 RX buffer, process it, and write to codec 2 TX buffer.

  - Read data from codec 2 RX buffer, process it, and write to codec 1 TX buffer.

 

- For processing, you can do simple re-transmission, mixing, filtering etc. depending on your needs. 

 

- Handle synchronization properly between tasks to avoid data corruption.

 

This approach allows implementing a straightforward full duplex bidirectional exchange between the codecs. Let me know if you have any other questions!

Also you can check this post it's not updated but it can help you start. 

Hope this helps you. If you're question is answered please mark this answer as best answer to be diffused.

Best Regards.

II

View solution in original post

6 REPLIES 6
Mahmoud Ben Romdhane
ST Employee

Hello @mick mick.

First thank you for posting and welcome to ST Community.

I suggest that you consult this article. It explains what is I2C is and how to use it through examples.

Getting started with I2C - stm32mcu.

You can also view this training lab: 

STM32L4 training: 05.6 Communication peripherals - Hands-on I2C - YouTube

Thanks. 

Mahmoud.

 

Issamos
Lead II

Hello @mick  

Here are a few tips to implement bidirectional audio data exchange between two audio codecs with an STM32H745:

 

- Configure I2S or SPI peripherals for communication with each codec. 

 

- Use circular buffers (ring buffers) to store received and transmit data. One buffer for each direction.

 

- In I2S/SPI RX interrupts, store received data into the corresponding RX buffer.

 

- In I2S/SPI TX interrupts, send data from the corresponding TX buffer. 

 

- In the main loop:

  - Read data from codec 1 RX buffer, process it, and write to codec 2 TX buffer.

  - Read data from codec 2 RX buffer, process it, and write to codec 1 TX buffer.

 

- For processing, you can do simple re-transmission, mixing, filtering etc. depending on your needs. 

 

- Handle synchronization properly between tasks to avoid data corruption.

 

This approach allows implementing a straightforward full duplex bidirectional exchange between the codecs. Let me know if you have any other questions!

Also you can check this post it's not updated but it can help you start. 

Hope this helps you. If you're question is answered please mark this answer as best answer to be diffused.

Best Regards.

II

thanks for your reply, but my question about i2s protocol

Thanks very much, your answer was  useful and now I can continue my work

Hello Issamos

Sorry for my frequently questions

can you support me by simple code that may be very useful.

sorry again.

Hello @mick  

For now I don't have a ready answer. I Will look for some exemples. But is going to be better if you ask a new question to give your request more visibility.

Best regards.

II