I2S record and play at the same time #9243
-
Hi, I would like to use a Teensy audio board with an ESP32. (The SGTL5000 has 1 I2s interface SCK, WS, D_IN and D_OUT) Can I just use this? Or do I need 2 physical I2S busses? I base my experiments on @miketeachman's great implementation and examples at: https://github.com/miketeachman/micropython-i2s-examples
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, The following is a technical explanation on why two busses will not work. After configuring two I2S busses, one TX and the other RX, an oscilloscope shows that the SCK and WS signals for TX and RX do not line up. This situation causes a problem when using the SGTL5000 codec, which only accepts one SCK and one WS signal. Suppose the SCK and WS signals for the I2S TX bus are connected to the SCK and WS signals on the SGTL5000 codec (and the SCK and WS signals for the I2S RX bus are not used). The codec will "clock in" the TX data using the SCK and WS signals from the I2S TX bus. This results in the codec working for the TX direction. The expected audio sounds will be created. But, for the RX direction there is a problem -- the codec will send RX data to the 2nd I2S bus using the SCK and WS signals generated from the I2S TX bus. This is where the problem appears - for correct operation the I2S RX bus needs the first bit of each 32-bit audio sample aligned with its own SCK and WS signals. But, the I2S RX bus receives each 32-bit audio sample that has been aligned with the SCK and WS TX signals (which are not aligned with the SCK and WS RX signals). So, the I2S RX bus clocks in each audio sample in the wrong bit location. e.g. the 5th sample bit might be clocked in as the 0th sample bit. The result will be noise received on the RX bus. A possible solution is using two Teensy audio boards, one for each of the TX and RX busses. One other challenge using the ESP32 with the SGTL5000 codec is lack of a Master clock. The SGTL5000 codec requires a Master clock which is not provided by the MicroPython I2S implementation for the ESP32. Using the I hope this helps! Mike |
Beta Was this translation helpful? Give feedback.
Hi,
The MicroPython I2S implementation is half-duplex so it will not be possible to use one I2S bus for both read and write operations. Unfortunately, using 2 I2S busses will not work either as each ESP32 I2S peripheral outputs SCK and WS signals that are asynchronous.
The following is a technical explanation on why two busses will not work.
After configuring two I2S busses, one TX and the other RX, an oscilloscope shows that the SCK and WS signals for TX and RX do not line up. This situation causes a problem when using the SGTL5000 codec, which only accepts one SCK and one WS signal. Suppose the SCK and WS signals for the I2S TX bus are connected to the SCK and WS signals on the SGTL5000…