Skip to main content
Associate II
August 31, 2023
Solved

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

  • August 31, 2023
  • 6 replies
  • 2709 views

 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

    This topic has been closed for replies.
    Best answer by Issamos

    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

    6 replies

    ST Technical Moderator
    August 31, 2023

    Hello @mickmick.

    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.

     

    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.
    mickAuthor
    Associate II
    September 3, 2023

    thanks for your reply, but my question about i2s protocol

    Issamos
    IssamosBest answer
    Super User
    August 31, 2023

    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

    mickAuthor
    Associate II
    September 3, 2023

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