I'm working on a USB to I2S bridge targeting 32 bits x 8 channels and 96kHz. It is to be based on ESP components esp_codec_dev and usb_device_uac. First implementation with i2s 16 bits stereo is working with my Codec, but I don't have sound when I configure usb_device_uac with 32 bits samples. I2S is configured in master mode.
With the logic analyzer I identified that I have data bits edges not in sync with the bclk falling edges. See first attachment.
Hoever on the same board and similar initialization, the i2s peripheral example has its data edges well synchronized with the bclk (same board, same pins, same measurement setup.
Both codes return same debug logs, so initialization seems similar and OK on both:
My code:
D (332) i2s_common: DMA malloc info: dma_desc_num = 8, dma_desc_buf_size = dma_frame_num * slot_num * data_bit_width = 768
D (342) i2s_std: Clock division info: [sclk] 40000000 Hz [mdiv] 3 49/192 [mclk] 12288000 Hz [bdiv] 4 [bclk] 3072000 Hz
D (352) i2s_common: MCLK is pinned to GPIO16 on I2S0
D (362) i2s_std: The tx channel on I2S0 has been initialized to STD mode successfully
D (362) i2s_common: i2s rx channel enabled
D (372) i2s_common: i2s tx channel enabled
W (372) DUMMY_CODEC: PA control disabled, gpio_if:0x4ff3d62c pa_pin:-1
D (382) i2s_common: i2s tx channel disabled
I (382) I2S_IF: Paired data: 0x4ff3f404, current mode: playback, paired in_enable: 0, paired out_enable: 0
D (392) i2s_std: Clock division info: [sclk] 40000000 Hz [mdiv] 3 49/192 [mclk] 12288000 Hz [bdiv] 4 [bclk] 3072000 Hz
I (402) I2S_IF: STD: TX, data_bit: 32, slot_bit: 32, ws_width: 32, slot_mode: STEREO, slot_mask: 0x3
I (412) I2S_IF: STD: TX, sample_rate_hz: 48000, mclk_multiple: 256, clk_src: 0
D (422) i2s_common: i2s tx channel enabled
Example code:
D (278) i2s_common: tx channel is registered on I2S0 successfully
D (278) i2s_common: rx channel is registered on I2S0 successfully
D (288) i2s_common: DMA malloc info: dma_desc_num = 6, dma_desc_buf_size = dma_frame_num * slot_num * data_bit_width = 1920
D (298) i2s_std: Clock division info: [sclk] 40000000 Hz [mdiv] 3 49/192 [mclk] 12288000 Hz [bdiv] 4 [bclk] 3072000 Hz
D (308) i2s_common: MCLK is pinned to GPIO16 on I2S0
D (308) i2s_std: The tx channel on I2S0 has been initialized to STD mode successfully
D (318) i2s_common: DMA malloc info: dma_desc_num = 6, dma_desc_buf_size = dma_frame_num * slot_num * data_bit_width = 1920
D (328) i2s_std: Clock division info: [sclk] 40000000 Hz [mdiv] 3 49/192 [mclk] 12288000 Hz [bdiv] 4 [bclk] 3072000 Hz
D (338) i2s_common: MCLK is pinned to GPIO16 on I2S0
D (348) i2s_std: The rx channel on I2S0 has been initialized to STD mode successfully
D (348) i2s_common: i2s rx channel enabled
D (358) i2s_common: i2s tx channel enabled
My code attached. For me the synch between data bits and bclk is done by the peripheral (hardware). I work on this since a week part time and I failed to identify:
- what can cause this those data bits not in synch with bclk in Master mode in my code,
- what is the difference that makes that the i2s example code is showing good behaviour, and not my code.
Help very welcomed to save the WeekEnd
Best regards,
JMF