Below is part of the code......The example given is to play sound out from I2S port. I dont have an I2S amplifier etc so thought I could set it up to use the BUILT_IN DAC for audio out. The docs show how to do this. I have made the changes to the code as I think but do not get any sound out at all It is supposed to use I2S_num 0 and defaults output to gpio 25 and 26. I am not using any other pins for anything else.
The program compiles, flashes and uploads to the board. ....need some help please........
Code: Select all
void app_main()
{
//for 36Khz sample rates, we create 100Hz sine wave, every cycle need 36000/100 = 360 samples (4-bytes or 8-bytes each sample)
//depend on bits_per_sample
//using 6 buffers, we need 60-samples per buffer
//if 2-channels, 16-bit each channel, total buffer is 360*4 = 1440 bytes
//if 2-channels, 24/32-bit each channel, total buffer is 360*8 = 2880 bytes
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN, // Only TX.....I added DAC BUILTIN....XXXXXXX
.sample_rate = SAMPLE_RATE,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //2-channels
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 6,
.dma_buf_len = 60, //
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 //Interrupt level 1
};
i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 22,
.data_in_num = -1 //Not used
};
i2s_driver_install(I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin(I2S_NUM, NULL); // Docs say set to NULL for DAC builtin....XXXXXXXXXX
int test_bits = 16;
while (1) {
setup_triangle_sine_waves(test_bits);
vTaskDelay(5000/portTICK_RATE_MS);
test_bits += 8;
if(test_bits > 32)
test_bits = 16;
}
}