ELF file SHA256: ade600cdbebfe4fa
E (158) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
E (166) esp_core_dump_elf: Elf write init failed!
E (171) esp_core_dump_common: Core dump write failed with error=-1
Rebooting...
ets Jul 29 2019 12:21:46
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 153911750, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
E (138) ADC: CONFLICT! driver_ng is not allowed to be used with the legacy driver
abort() was called at PC 0x400d8bdf on core 0
Backtrace: 0x4008237d:0x3ffe3b30 0x4008863d:0x3ffe3b50 0x4008d5e5:0x3ffe3b70 0x400d8bdf:0x3ffe3bf0 0x400db136:0x3ffe3c10 0x400826aa:0x3ffe3c40 0x400797e5:0x3ffe3c80 |<-CORRUPTED
附上我的代码:
Code: Select all
#include "driver/i2s.h"
#include "math.h"
//引脚定义:
#define INMP_SD_NUM 17
#define INMP_WS_NUM 18
#define INMP_SCK_NUM 4
//#define INMP_OUT_NUM I2S_PIN_NO_CHANGE
//i2s参数设置
i2s_port_t I2S_PORT = I2S_NUM_0;
i2s_pin_config_t INMP441_PIN;
i2s_driver_config_t INMP441_config;
//i2s初始化函数
void my_i2s_INMP441(){
INMP441_PIN.bck_io_num = INMP_SCK_NUM;
INMP441_PIN.ws_io_num = INMP_WS_NUM;
INMP441_PIN.data_out_num = -1;
INMP441_PIN.data_in_num = INMP_SD_NUM;
INMP441_config.mode =i2s_mode_t(I2S_MODE_MASTER|I2S_MODE_RX);//I2S_MODE_MASTER(主模式)、I2S_MODE_SLAVE(从模式)和I2S_MODE_TX(以传输为主的从模式)
INMP441_config.sample_rate = 44100; //设置采样率,即音频数据每秒钟的样本数。可以选择16000、32000、44100、48000等不同值。
INMP441_config.bits_per_sample = i2s_bits_per_sample_t(16); //设置每个采样的位数。常见的位数为16位或32位。
INMP441_config.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT;//设置音频通道的格式。可以选择I2S_CHANNEL_FMT_ONLY_LEFT(仅左声道)、I2S_CHANNEL_FMT_ONLY_RIGHT(仅右声道)或I2S_CHANNEL_FMT_RIGHT_LEFT(左右声道交替)。
INMP441_config.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S|I2S_COMM_FORMAT_I2S_MSB); //设置I2S接口的通信格式。可选的格式有I2S_COMM_FORMAT_I2S(标准I2S格式)、I2S_COMM_FORMAT_I2S_MSB(带主导的MSB对齐格式)和I2S_COMM_FORMAT_PCM(PCM格式)。
INMP441_config.intr_alloc_flags = 0;//设置中断分配标志,用于控制中断服务程序的分配和管理。可选的标志有ESP_INTR_FLAG_LEVEL1、ESP_INTR_FLAG_LEVEL2和ESP_INTR_FLAG_LEVEL3。
INMP441_config.dma_buf_count = 4;//设置dma数量
INMP441_config.dma_buf_len = 1024;//设置dma长度,最长为4096
//估计还是要改,查到的参数有2/256,4/1024等
INMP441_config.use_apll = true; //设置是否使用APLL作为主要的I2S时钟。如果设置为true,可以获得更准确的时钟。
//INMP441_config.tx_desc_auto_clear = true; //设置是否在发生数据不可用情况下自动清除传输描述符,以避免噪声。如果发生数据不足条件,可以通过启用此选项自动清除TX描述符。
//INMP441_config.fixed_mclk = ; //设置是否使用固定的MCLK输出。如果use_apll设置为true并且fixed_mclk大于0,则I2S的时钟输出将固定并等于fixed_mclk的值。如果设置了fixed_mclk,mclk_multiple将不起作用。
//INMP441_config.mclk_multiple = I2S_MCLK_MULT_1;//设置I2S主时钟(MCLK)与采样率之间的倍数关系。可以选择I2S_MCLK_MULT_1、I2S_MCLK_MULT_2等多个倍数关系。
//INMP441_config.bits_per_chan = I2S_BITS_PER_CHAN_16; //设置每个通道的位数。可选择的位数包括I2S_BITS_PER_CHAN_8、I2S_BITS_PER_CHAN_16、I2S_BITS_PER_CHAN_24和I2S_BITS_PER_CHAN_32
esp_err_t err = i2s_driver_install(I2S_PORT,&INMP441_config,0,NULL); // 调用某个函数,返回一个错误码
if (err != ESP_OK) {
Serial.print("i2s初始化失败。Error occurred: ");
Serial.println(esp_err_to_name(err)); // 将错误码转换为可读的字符串并打印输出
}
else{
Serial.println("i2s初始化成功");
}
i2s_set_pin(I2S_PORT,&INMP441_PIN);
i2s_stop(I2S_PORT);//初始化启用服务以后,暂时关闭启用的I2S。
}
void setup() {
// initialize serial communication at 115200 bits per second:
Serial.begin(115200);
//set the resolution to 12 bits (0-4095)
analogReadResolution(12);
my_i2s_INMP441();
}
void loop() {
// read the analog / millivolts value for pin 2:
int analogValue = analogRead(35);
int analogVolts = analogReadMilliVolts(35);
// print out the values you read:
Serial.printf("ADC analog value = %d\n", analogValue);
Serial.printf("ADC millivolts value = %d\n", analogVolts);
delay(100); // delay in between reads for clear read from serial
}