esp32:wm8782
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| esp32:wm8782 [2021/05/17 21:38] – created aistis | esp32:wm8782 [2021/05/18 12:33] (current) – aistis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| WM8782 i2s ADC esp32 | WM8782 i2s ADC esp32 | ||
| + | |||
| + | https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | some code that helped: https:// | ||
| + | |||
| + | <code cpp> | ||
| + | #include < | ||
| + | |||
| + | const i2s_port_t I2S_PORT = I2S_NUM_0; | ||
| + | |||
| + | #include " | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | |||
| + | Serial.println(" | ||
| + | esp_err_t err; | ||
| + | |||
| + | int SAMPLE_RATE = 8000; //44100; //16000; //44100; //44100; // 100000; //176400; //96000; //96000; | ||
| + | |||
| + | const i2s_config_t i2s_config = { | ||
| + | .mode = i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX), | ||
| + | //.mode = i2s_mode_t(I2S_MODE_SLAVE | I2S_MODE_RX), | ||
| + | .sample_rate = | ||
| + | .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, | ||
| + | .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, | ||
| + | // .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, | ||
| + | .communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB), | ||
| + | .intr_alloc_flags = 0, | ||
| + | .dma_buf_count = 16, | ||
| + | .dma_buf_len = 256 | ||
| + | }; | ||
| + | |||
| + | const i2s_pin_config_t pin_config = { | ||
| + | .bck_io_num = 14, // BCKL SCK BCLK | ||
| + | .ws_io_num = 15, // LRCL LRCLK FS | ||
| + | .data_out_num = -1, // not used (only for speakers) | ||
| + | .data_in_num = 32 // DOUT SD SDATA, SDIN, SDOUT, DACDAT, ADCDAT | ||
| + | }; | ||
| + | |||
| + | // Configuring the I2S driver and pins. | ||
| + | // This function must be called before any I2S driver read/write operations. | ||
| + | err = i2s_driver_install(I2S_PORT, | ||
| + | if (err != ESP_OK) { | ||
| + | Serial.printf(" | ||
| + | while (true); | ||
| + | } | ||
| + | err = i2s_set_pin(I2S_PORT, | ||
| + | if (err != ESP_OK) { | ||
| + | Serial.printf(" | ||
| + | while (true); | ||
| + | } | ||
| + | Serial.println(" | ||
| + | |||
| + | // PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, | ||
| + | // WRITE_PERI_REG(PIN_CTRL, | ||
| + | |||
| + | REG_WRITE(PIN_CTRL, | ||
| + | PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, | ||
| + | // | ||
| + | |||
| + | // mcpwm_gpio_init(MCPWM_UNIT_0, | ||
| + | // mcpwm_pin_config_t pin_config = { | ||
| + | // .mcpwm0a_out_num = I2S_MCLK | ||
| + | // }; | ||
| + | // mcpwm_set_pin(MCPWM_UNIT_0, | ||
| + | // gpio_pulldown_en(I2S_MCLK); | ||
| + | // mcpwm_config_t pwm_config; | ||
| + | // pwm_config.frequency = (SAMPLE_RATE) * 256; //when frequency is too high (actually only 1MHZ)there is no signal | ||
| + | // pwm_config.cmpr_a = 50.0; | ||
| + | // pwm_config.cmpr_b = 50.0; | ||
| + | // pwm_config.counter_mode = MCPWM_UP_COUNTER; | ||
| + | // pwm_config.duty_mode = MCPWM_DUTY_MODE_0; | ||
| + | // mcpwm_init(MCPWM_UNIT_0, | ||
| + | } | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | const int numCommunicationData = 256; //256; //1400; | ||
| + | unsigned char communicationData[numCommunicationData]; | ||
| + | void loop() { | ||
| + | int num_bytes_read = i2s_read_bytes(I2S_NUM_0, | ||
| + | // auto maxv = *std:: | ||
| + | // auto minv = *std:: | ||
| + | // Serial.printf(" | ||
| + | |||
| + | auto v1 = *((int32_t*)communicationData + 0); | ||
| + | auto v2 = *((int32_t*)communicationData + 1); | ||
| + | Serial.printf(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | simmilar board | ||
| + | |||
| + | {{: | ||
esp32/wm8782.1621276705.txt.gz · Last modified: by aistis
