2023-08-31 06:01 AM - edited 2023-08-31 07:22 AM
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
Solved! Go to Solution.
2023-08-31 09:15 AM
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
2023-08-31 08:41 AM
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.
2023-08-31 09:15 AM
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
2023-09-03 12:12 AM
thanks for your reply, but my question about i2s protocol
2023-09-03 12:55 AM
Thanks very much, your answer was useful and now I can continue my work
2023-09-14 05:52 AM
Hello Issamos
Sorry for my frequently questions
can you support me by simple code that may be very useful.
sorry again.
2023-09-14 05:56 AM
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