I2S Half Duplex Question #9639
-
My audio application is half-duplex; I want to record and playback using one I2S port, but not at the same time. My preferred codec is ADAU1361. This device has one SCK (BCLK), one WS (LRCLK) and two SD (ADC_SDATA and DAC_SDATA). The device also requires an MCLK, which I will supply with a crystal. I want to interface ADAU1361 to an ESP32. I think I can configure one ESP32 I2S port as an audio input, and configure the other as an output during playback. The same pins on ESP32 will be used for SCK and WS for record and playback, and will be connected to ADAU1361 BCLK and LRCLK, respectively. I will use different pins on the ESP32 for SD to connect to the ADAU1361 ADC_SDATA and DAC_SDATA pins. Is this scheme feasible with the current Micropython I2S implementation for ESP32? I noted the limitations in the discussion here, but in that case, the user's application is full duplex. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 18 replies
-
I expect you'll have the same issue as described in the discussion #9243. I don't know of a way to synchronize the two I2S peripherals on the ESP32 (so that the WS clocks are synchronous). Perhaps there is an ESP-IDF setting that enables this, but I haven't seen it. Your easiest solution is to use two different I2S hardware devices, one for Tx, the other for Rx. |
Beta Was this translation helpful? Give feedback.
-
Did you get the opportunity to read the answer section of the discussion https://github.com/orgs/micropython/discussions/9243? |
Beta Was this translation helpful? Give feedback.
-
I'm glad to hear that you think it should work to use a codec with a single I2S port for record and playback (half-duplex). I think Robert will confirm this tomorrow with his setup using WM8960. Full duplex operation might be a possibility. I wonder how much demand there is for this enhancement? I think PDM is useful -- there quite a few PDM microphones. Some have the sound port on the top, which can make them easier to work with in pcb assembly. Is there a top-port I2S microphone? I've only seen bottom-port with I2S. PDM also saves a pin, since you get two mics on the one data line with a double-data rate clock line. On the PDM output side, this can be used to create an analog output with an external filter-- and since the newer ESP32s don't include DACs, this is the only way that I see to get an analog output without using a lot of GPIOs. I also think TDM is interesting. There are some mulit-channel codecs out there (more than two ADCs or DACs), and usually the only way to interface to them is TDM. This of course only makes sense if the uC is powerful enough to do something useful with all these channels, but probably if you let people push the envelope, they will come up with some very interesting ideas .. |
Beta Was this translation helpful? Give feedback.
-
As expected, recording works as well, tested with the built-in microphone of the breakout. Test-Setup of the WM8960:
Recording:
With SAMPLE_RATE_IN_HZ set to the intended rate, like 44_100 or 32_000. The MCLK of the used Waveshare WM8960 breakout is fixed at 24MHz and cannot be supplied by the ESP32. It could only be fed from the breakout to the MCU. |
Beta Was this translation helpful? Give feedback.
-
Okay, thank you. I was thinking that I could configure the codec as I2S
controller, and the ESP32S3 as I2S peripheral. I thought this may work,
since the codec would provide the bit clock and the frame clock to both I2S
ports of the ESP32S3, and since this configuration (codec I2S controller,
ESP32 I2S peripheral) is supported according to the documentation of the
codec and the ESP32S3. But I see now in the Micropython documentation,
that the ESP32 can only be configured as an I2S controller. And I see your
point on why the other way won't work (ESP32 I2S controller, codec I2S
peripheral)
…On Sun, Apr 2, 2023 at 10:03 PM Mike Teachman ***@***.***> wrote:
Unfortunately it's not possible for the reason described here
<#9243 (comment)>
—
Reply to this email directly, view it on GitHub
<#9639 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGH5SSXEWEL2YBPEHWP2JILW7IVYBANCNFSM6AAAAAARGLJQ2E>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
As expected, recording works as well, tested with the built-in microphone of the breakout. Test-Setup of the WM8960:
Playback:
Recording: