-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Enable I2S for ESP32C6 (ESP32_GENERIC_C6) #17644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
I'm having issues confirming this with PCM5102A (see here). I doubt it, but could there be an issue with PCM5102A and MicroPython in general? Would be nice if someone could verify this PR. @steve1780 might be able to test it. |
I was not able to run the test code directly as I dont have a sd module at the moment, but I did some testing on the XIAO ESP32C6. As you know the ESP32C6 allows any GPIO pin to be assigned to any hardware block. In this case we are looking at the I2S on the C6 in which there is only one block (I2S_ID=0). I tested the pins from my original configuration: I also tested your configuration: I did try other GPIO combinations like: I used Mike Teachman's code to test this. |
Just to confirm, you mention SD_PIN but say that you didn't have an SD module. I used:
and you wrote that you tested my configuration:
It seems as if we are using different PINs.
Did you use this example. I had an issue with that example it seems as if dataformat, channelformat etc does not exist in MicroPython 1.25/1.26. My code looks as follows: # I2S pin configuration for PCM5102A
I2S_BCK_PIN = 22 # Bit Clock
I2S_DATA_PIN = 21 # Data In
I2S_LCK_PIN = 20 # Word Select (LRCK)
audio_out = I2S(
I2S_ID,
sck=Pin(I2S_BCK_PIN),
ws=Pin(I2S_LCK_PIN),
sd=Pin(I2S_DATA_PIN),
mode=I2S.TX,
bits=wav_info["bits_per_sample"],
format=I2S.STEREO,
rate=24000,
ibuf=2048,
) Looking at it now it seems as if I'm using the wrong PINs unless there is a different between your module and mine (PCM5201A). What module do you use? ![]() |
I found some more information now on the PCM5201A (which also in the datasheet). I'll have to do some more soldering to configure it correctly. pschatzmann/arduino-audio-tools#773 (comment) https://community.home-assistant.io/t/i2s-audio-with-pcm5102a/739461/6 |
Poor use of terms. SD_PIN just means "serial data". I am using the exact same PCM5201A module. I really suspect the use of GPIO20 is the culprit. Which ESP32 board are you using? |
Ok.
Yes, I believe so too now that I know that you use the PCM5201A module as well. If I may ask, just to save some time. How did you configure H1-H4, i.e solder?
and also full PIN configuration:
|
Too bad about the origin of the board. It would help to know the pinout. Back in the ESP32-WROOM days they were alot more standardized. Now, we are not guaranteed to have Vcc and Gnd in the same place. I don't even trust Seeed with their C6 pinout diagram. Gotta look at the schematics. I'm powering the PCM5201 board VIN with 3v3 from the ESP32C6 regulator. I'm not sure how the SCK works, I'm tying it to Gnd as others have suggested. I did not touch H1-H4. They seem to be in the positions you indicated. |
I'm not very good at soldering or electronics in general but I'm learning. So, I resolded so that I can use 3 header pins between the ESP32 and the PCM5201A.
Would you mind testing if that works for you? After some digging I think that I found my board (wuxx nanoesp32-c6):
The troubleshooting now is mainly for me to feel confident about this PR working. Although you've managed to confirm that it works for you, so in theory it should be ready for merge. |
@jimisola - Your new pin configuration works just fine. |
Great. Thank for confirming that. Something else wrong at my end then. |
@steve1780 We are troubleshooting here now and on my C6 I don't get a signal on WS. So, we'll try to rule out the following now:
|
@steve1780 We got it to work on my ESPC6 and ESPC3 🚀 For ESPC6 we used: I2S_BCK_PIN = 9 # Bit Clock and SCK connected to ground. Let's hope that some maintainer accept this PR now. |
@jimisola, |
Forgot to say that we tried PIN 20 and 21. None of them worked (not output voltage). I don't think that this is an issue with the I2S implementation for C6 but rather the way some Dev Boards have their pinout. |
Summary
The ESP32_GENERIC_C6 firmware doesn't support I2S. This PR enables I2S support.
Fixes: https://github.com/orgs/micropython/discussions/17151
Testing
The I2S import works but I'm yet to test that the audio actually works. But, according to @steve1780 who also custom built the firmware it worked for him: https://github.com/orgs/micropython/discussions/17151#discussioncomment-12925674