TDM audio problem in ESP32S3

MarcelloM
Posts: 1
Joined: Tue Oct 18, 2022 3:54 pm

TDM audio problem in ESP32S3

Postby MarcelloM » Wed Oct 19, 2022 9:13 am

I try to receive and send audio by PCM3168A with I2S TDM and it's all ok with 4 channels 24bit , but if I need more 6 for RX and 8 for TX and control WS and bit data I receive nothing only the clock and the master clock working, why?
  1. [Codebox=text file=Untitled.txt]
[/Codebox]
my program is this :
void i2sInit(){
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
.sample_rate = I2S_SAMPLE_RATE,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_MULTIPLE ,
//.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = BUF_SIZE,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0,
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
.bits_per_chan = I2S_BITS_PER_CHAN_24BIT,
.chan_mask = (i2s_channel_t )(I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH1 | I2S_TDM_ACTIVE_CH2 | I2S_TDM_ACTIVE_CH3 ) ,
.total_chan = 4
};

i2s_config_t i2s_config2 = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = I2S_SAMPLE_RATE,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,
.channel_format = I2S_CHANNEL_FMT_MULTIPLE ,
// .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_STAND_I2S,
.intr_alloc_flags = 0, // default interrupt priority
.dma_buf_count = 8,
.dma_buf_len = BUF_SIZE,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0,
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
.bits_per_chan = I2S_BITS_PER_CHAN_24BIT,
.chan_mask = (i2s_channel_t )(I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH1 | I2S_TDM_ACTIVE_CH2 | I2S_TDM_ACTIVE_CH3 ),
.total_chan = 4
};

static const i2s_pin_config_t pin_config = {
.mck_io_num = 0,
.bck_io_num = 16,
.ws_io_num = 8,
.data_out_num = 5,
.data_in_num = I2S_PIN_NO_CHANGE
};

static const i2s_pin_config_t pin_config2 = {
.mck_io_num = 0,
.bck_io_num = 6,
.ws_io_num = 7,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = 15
};

if(ESP_OK != i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL)){
Serial.printf("Error installing I2S. Halt!");
while(1);
}
if(ESP_OK != i2s_driver_install(I2S_NUM_1, &i2s_config2, 0, NULL)){
Serial.printf("Error installing I2S. Halt!");
while(1);
}
//REG_SET_BIT( I2S_TIMING_REG(i2s_num),BIT(9));
//REG_SET_BIT( I2S_CONF_REG(i2s_num), I2S_RX_MSB_SHIFT);
i2s_set_pin(I2S_NUM_0, &pin_config);
i2s_set_pin(I2S_NUM_1, &pin_config2);
REG_SET_BIT(I2S_RX_CONF_REG(I2S_NUM_1),BIT(19)); //TDM enable
//REG_SET_BIT(I2S_RX_CONF_REG(I2S_NUM_1),BIT(16)); //24bit in 32 bit
//REG_CLR_BIT(I2S_RX_CONF1_REG(I2S_NUM_1),BIT(16)); //24 bit TDM
//REG_SET_BIT(I2S_RX_CONF1_REG(I2S_NUM_1),BIT(17)); //24 bit TDM
//REG_WRITE(I2S_RX_CONF1_REG(I2S_NUM_1), 0x37C2E05F);

uint32_t new_val = REG_READ(I2S_RX_CONF_REG(I2S_NUM_1));
Serial.println();
Serial.print("I2S_RX_CONF_REG =");
Serial.println(new_val, HEX);
new_val = REG_READ(I2S_RX_CONF1_REG(I2S_NUM_1));
Serial.println();
Serial.print("I2S_RX_CONF1_REG =");
Serial.println(new_val, HEX);
new_val = REG_READ(I2S_RX_CLKM_CONF_REG(I2S_NUM_1));
Serial.println();
Serial.print("I2S_RX_CLKM_CONF_REG =");
Serial.println(new_val, HEX);
new_val = REG_READ(I2S_RX_TDM_CTRL_REG(I2S_NUM_1));
Serial.println();
Serial.print("I2S_RX_TDM_CTRL_REG =");
Serial.println(new_val, HEX);
}

Who is online

Users browsing this forum: No registered users and 152 guests