ESP32 LyraT v4.3 I2S_Read一直返回0,用官方的pipeline_passthru烧录运行就好了

beyound
Posts: 20
Joined: Sat Jan 01, 2022 9:55 am

ESP32 LyraT v4.3 I2S_Read一直返回0,用官方的pipeline_passthru烧录运行就好了

Postby beyound » Sat Jan 01, 2022 10:10 am

但是断电以后,I2S_Read又会取得全部都是0的数据。每次我都要先烧录运行一下 ADF的pipeline_passthru例程,然后再烧录我的DSP程序,才能正常的I2S_Read, 这也是我无意中发现的。

请问是我的硬件有什么问题吗?还是我用的代码有问题?

Code: Select all

i2s_config_t i2s_read_config = {
		.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX,
		.sample_rate = 44100,
		.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, 
		.communication_format = I2S_COMM_FORMAT_STAND_I2S, 
		.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
		.intr_alloc_flags = ESP_INTR_FLAG_LEVEL2 | ESP_INTR_FLAG_IRAM,
		.dma_buf_count = 3,
		.dma_buf_len = I2S_READLEN,
		.use_apll = true,
		.tx_desc_auto_clear = true,
		.fixed_mclk = 0
	};

	i2s_pin_config_t i2s_read_pin_config = {
		.bck_io_num = GPIO_NUM_5,
		.ws_io_num = GPIO_NUM_25,
		.data_out_num = GPIO_NUM_26,
		.data_in_num = GPIO_NUM_35
	};

	i2s_driver_install(I2S_NUM, &i2s_read_config, 0, NULL);
	i2s_set_pin(I2S_NUM, &i2s_read_pin_config);
	
		/*******************/

	printf("[filter-dsp] Initializing MCLK output...\r\n");

	PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
	WRITE_PERI_REG(PIN_CTRL, 0xFFF0);

	/*******************/

	printf("[filter-dsp] Enabling Passthrough mode...\r\n");

	size_t i2s_bytes_read = 0;
	size_t i2s_bytes_written = 0;

	int16_t i2s_buffer_read[I2S_READLEN / sizeof(int16_t)];
	int16_t i2s_buffer_write[I2S_READLEN / sizeof(int16_t)];
	
		while (true) {

		


		i2s_bytes_read = I2S_READLEN;
		i2s_read(I2S_NUM, i2s_buffer_read, I2S_READLEN, &i2s_bytes_read, 100);

		/* left channel filter */
		for (uint32_t i = 0; i < i2s_bytes_read / 2; i += 2)
		{

		//	  printf("left: %d\r\n", i2s_buffer_read[i]);

			
			i2s_buffer_write[i] = processSample(i2s_buffer_read[i]);

		 	// printf("left OUT: %d\r\n", i2s_buffer_write[i]);

		}
			

		/* right channel filter */
		for (uint32_t i = 1; i < i2s_bytes_read / 2; i += 2)
			i2s_buffer_write[i] = dummyfilter(i2s_buffer_read[i]) ;

		esp_err_t err = i2s_write(I2S_NUM, i2s_buffer_write, i2s_bytes_read, &i2s_bytes_written, 100);
		ESP_ERROR_CHECK_WITHOUT_ABORT(err);    

		

	}
	
	
	

我用的开发板是 ESP32 LYRAT 4.3,板载的DAC是8388。我要实现的功能其实非常简单, 模拟信号从LINE IN输入,我I2S_READ读取,处理数据后, I2S_WRITE输出。

上述代码运行没有任何报错,但是i2s_read返回的都是0。

没有人遇到跟我一样的问题吗?网上搜了很多资料,发现没人反馈这个问题。

beyound
Posts: 20
Joined: Sat Jan 01, 2022 9:55 am

Re: ESP32 LyraT v4.3 I2S_Read一直返回0,用官方的pipeline_passthru烧录运行就好了

Postby beyound » Mon Jan 03, 2022 5:17 am

这个问题已经解决了,我用的库文件没有很好的给ES8388上电,改了一下已经解决了。

但是很奇怪的是,如果用pipeline的方式实现播放和回放,没有办法用回调函数读取sample数据,所有的缓存都是0.

把line in 改成 both(line in & mic)就可以了,但是我不需要mic的数据采样啊。

Who is online

Users browsing this forum: No registered users and 15 guests