i2s read causes ESP32-C6 to Crash??

UnknownBotIndustries
Posts: 6
Joined: Mon Apr 01, 2024 3:22 am

i2s read causes ESP32-C6 to Crash??

Postby UnknownBotIndustries » Mon Apr 01, 2024 3:52 am

Hey all, I'm having this really weird issue with a setup between my ESP32-C6-WROOM-1 and an AK5720VT. When I run the following code:
[Codebox]#include <stdio.h>
#include <driver\i2s_std.h>
#include "driver\gpio.h"
#include "freeRTOS\freeRTOS.h"
#include "freeRTOS\task.h"

void app_main(void)
{
printf("Hello world!\n");
gpio_reset_pin(GPIO_NUM_5);
gpio_set_direction(GPIO_NUM_5, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_5, 1);
gpio_reset_pin(GPIO_NUM_6);
gpio_set_direction(GPIO_NUM_6, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_NUM_6, 1);
i2s_chan_handle_t rx_handle;
i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_0, I2S_ROLE_MASTER);
i2s_new_channel(&chan_cfg, NULL, &rx_handle);

i2s_std_config_t std_cfg = {
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(44100),
.slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_24BIT, I2S_SLOT_MODE_MONO),
.gpio_cfg = {
.mclk = GPIO_NUM_19,
.bclk = GPIO_NUM_18,
.ws = GPIO_NUM_20,
.dout = GPIO_NUM_NC,
.din = GPIO_NUM_21,
.invert_flags = {
.mclk_inv = false,
.bclk_inv = false,
.ws_inv = false,
},
},
};
std_cfg.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_384;
i2s_channel_init_std_mode(rx_handle, &std_cfg);

i2s_channel_enable(rx_handle);
int32_t raw_samples[44100];
vTaskDelay(10000);
size_t bytes_read = 0;
i2s_channel_read(rx_handle, raw_samples, sizeof(int32_t) * 44100, &bytes_read, 20);
}[/Codebox]
The CPU immediately crashes after saying "Calling app_main()", and doesn't say anything else, causing the USB UART module of the ESP32-C6 to stop working, so I can't reprogram it over USB until I reprogram it over UART. If I take away the i2s_channel_read, the CPU acts like normal. What's going on? Is my config off or is there something wrong with the ESP32-C6? Many thanks to anyone who can answer. Also, the GPIOs I turn on at the beginning of my code correspond to the PDN and TDMI pins of the audio codec.
My schematics are in the attachments.
Screenshot 2024-03-31 205113.png
Screenshot 2024-03-31 205113.png (12.92 KiB) Viewed 524 times
Screenshot 2024-03-31 205101.png
Screenshot 2024-03-31 205101.png (27.15 KiB) Viewed 524 times

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: i2s read causes ESP32-C6 to Crash??

Postby ESP_Sprite » Mon Apr 01, 2024 7:52 am

You're allocating raw_samples on the stack, but I highly doubt you have that large a stack available.

Who is online

Users browsing this forum: No registered users and 63 guests