A2DP source using adc dma (i2s) not working

rupakj
Posts: 1
Joined: Thu Sep 10, 2020 9:40 am

A2DP source using adc dma (i2s) not working

Postby rupakj » Mon Sep 14, 2020 10:51 am

I have been trying to get the a2dp source example to work with ADC DMA. I am able to run the basic example and send noise audio.
Source esp-32 is able to connect to sink esp-32.
But when I connect data out from MAX9814( which I have confirmed to be working) on ADC channel 0 of source esp-32, I am not getting any audio on speaker connected to sink device.

code for I2S:

Code: Select all

int i2s_num = I2S_NUM_0;
	 i2s_config_t i2s_config = {
        .mode = I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN,
        .sample_rate =  44100,
        .bits_per_sample = 16,
	    .communication_format = I2S_COMM_FORMAT_I2S_MSB,
	    .channel_format = I2S_CHANNEL_FMT_ALL_LEFT,
	    .intr_alloc_flags = 0,
	    .dma_buf_count = 8,
	    .dma_buf_len = 1024,
	    .use_apll = false,
	 };

	 //install and start i2s driver
	 ESP_ERROR_CHECK(i2s_driver_install(i2s_num, &i2s_config, 0, NULL));

	 //init ADC pad
	 ESP_ERROR_CHECK(i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_0));
	 adc1_config_width(ADC_WIDTH_BIT_12);
   	 adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);

	 vTaskDelay(1000/portTICK_RATE_MS);	// Delay necessary for reliable start
	 i2s_adc_enable(I2S_NUM_0);


	// create a bype ring buffer for I2S audio
	buf_handle = xRingbufferCreate(8192, RINGBUF_TYPE_BYTEBUF);
changes in bt_app_a2d_data_cb function for reading the data :

Code: Select all

static int32_t bt_app_a2d_data_cb(uint8_t *data, int32_t len)
{
    if (len < 0 || data == NULL) {
        return 0;
    }

   size_t bytes_read;
    int16_t d1[len/2];
    i2s_read(I2S_NUM_0, (void*) d1, len, &bytes_read, portMAX_DELAY);    // read adc data from dma

    int countt = 0;
    memcpy(data, d1, len);*/
	return len;
}
log message shows that data is of 0 bytes on source esp-32
[Codebox]13:53:54.302 -> �[0;33mW (158595) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0m
13:53:54.302 -> �[0;33mW (158595) BT_APPL: btc_media_aa_prep_sbc_2_send underflow 4, 0�[0m
13:53:54.337 -> �[0;33mW (158615) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0m
13:53:54.337 -> �[0;33mW (158625) BT_APPL: btc_media_aa_prep_sbc_2_send underflow 6, 0�[0m
13:53:54.407 -> �[0;33mW (158675) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0m
13:53:54.407 -> �[0;33mW (158685) BT_APPL: btc_media_aa_prep_sbc_2_send underflow 3, 0�[0m
13:53:54.440 -> �[0;33mW (158715) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0m
13:53:54.440 -> �[0;33mW (158715) BT_APPL: btc_media_aa_prep_sbc_2_send underflow 5, 0�[0m
13:53:54.440 -> �[0;33mW (158735) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0m
13:53:54.474 -> �[0;33mW (158745) BT_APPL: btc_media_aa_prep_sbc_2_send underflow 7, 0�[0m
13:53:54.474 -> �[0;33mW (158775) BT_APPL: ### UNDERFLOW :: ONLY READ 0 BYTES OUT OF 512 ###�[0[/Codebox]

can anyone provide some pointer to proceed.

thanks,
rupak

Who is online

Users browsing this forum: Bing [Bot] and 43 guests