PCM1808 SCLK
-
- Posts: 4
- Joined: Sun Jan 15, 2023 12:57 am
PCM1808 SCLK
I'm currently using an ESP32-S3 to connect to a PCM1808 Audio ADC (https://www.ti.com/lit/gpn/pcm1808). The standard i2s example seems sufficient with one exception, the SCLK. The PCM1808 part requires a clock input which is it's sample clock:
In the i2s standard example (https://github.com/espressif/esp-idf/bl ... ple_main.c) there's the MCLK, BCLK, WS, and DOUT, but there is no SCLK:
So my question is, is there a way to create a "generic" clock output on a GPIO pin that's synchronous with other pins? Is there another more novel solution to this? The PCM1808 requires this clock to function, and surely there has to be a way to generate this clock, I'm just not familiar enough to know how.
In the i2s standard example (https://github.com/espressif/esp-idf/bl ... ple_main.c) there's the MCLK, BCLK, WS, and DOUT, but there is no SCLK:
So my question is, is there a way to create a "generic" clock output on a GPIO pin that's synchronous with other pins? Is there another more novel solution to this? The PCM1808 requires this clock to function, and surely there has to be a way to generate this clock, I'm just not familiar enough to know how.
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: PCM1808 SCLK
Looks like 'system clock'/SCLK is TIs equivalent to MCLK.
-
- Posts: 4
- Joined: Sun Jan 15, 2023 12:57 am
Re: PCM1808 SCLK
You may be right, I will try connecting as MCLK and try it out.
-
- Posts: 4
- Joined: Sat Mar 14, 2020 4:55 pm
Re: PCM1808 SCLK
Did it work? I'm looking at picking one of these up for a project and concerned about this issue as well.plasmaphase wrote: ↑Mon Jan 23, 2023 12:27 pmYou may be right, I will try connecting as MCLK and try it out.
Re: PCM1808 SCLK
@plasmaphase I'd also love to know if MCLK was the answer
Re: PCM1808 SCLK
Hi, yes the GPIO0 pin carries out the MCLK signal from I2S by default in the ESP32, it can go directly to pin 6 of PCM1808 (SCKI) or, better, you can do it through a 10 to 49 ohm resistor. As an example for plain ESP32 chip:
Code: Select all
#define SAMPLERATE 48000
#define BITS 16
#define NUMCHANNELS 2
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_RX,
.sample_rate = SAMPLERATE,
.bits_per_sample = BITS,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_STAND_MSB,
.dma_buf_count = 4,
.dma_buf_len = 240,
.use_apll = true,
.fixed_mclk = 256 * SAMPLERATE,
.tx_desc_auto_clear = true,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
Code: Select all
//I2S pinout example configuration
i2s_pin_config_t pin_config = {
.bck_io_num = 5,//BIT CLOCK(TO PIN 8 BCK IN PCM1808)
.ws_io_num = 25,//LR CLOCK(TO PIN 7 LRCK IN PCM1808)
.mck_io_num = 0,//MASTER CLOCK(TO PIN 6 SCKI IN PCM1808)
.data_out_num = -1,//(NOT USED)
.data_in_num = 35//DATA IN(FROM PIN 9 DOUT IN PCM1808)
};
ESP_ERROR_CHECK(i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL));
//this optional line reconfigures the default I2S asignment pins:
ESP_ERROR_CHECK(i2s_set_pin(I2S_NUM_0, &pin_config));
//this optional line configures the default MCLK rate:
ESP_ERROR_CHECK( i2s_set_clk(I2S_NUM_0, SAMPLERATE, BITS, NUMCHANNELS) );
Re: PCM1808 SCLK
Thanks! Got it running as well.
Re: PCM1808 SCLK
Hi guys,
I am using your sample code and I can see all of the clocks being sent to the PCM eval board. Unfortunately, it is not sending back any data when it is in slave mode, only when I use the onboard master oscillator.
Are there any other configs or timings missing from the sample code?
I am using your sample code and I can see all of the clocks being sent to the PCM eval board. Unfortunately, it is not sending back any data when it is in slave mode, only when I use the onboard master oscillator.
Are there any other configs or timings missing from the sample code?
Who is online
Users browsing this forum: Google [Bot] and 150 guests