The output signal is "silence" hovering at about +80mV
Another user reports the same behavior in this post.
Included below is a separate bare-bones example that should produce audio clicks.
Please prove me wrong.
Code: Select all
#include "driver/i2s.h"
#include "esp_err.h"
void app_main( void )
{
// configure i2s for internal dac
static const i2s_config_t i2s_config =
{
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
.sample_rate = 48000,
.bits_per_sample = 16,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = true
};
// install i2s driver
ESP_ERROR_CHECK( i2s_driver_install( I2S_NUM_0, &i2s_config, 0, NULL ) );
// set pins for internal dac - enable both channels
ESP_ERROR_CHECK( i2s_set_pin( I2S_NUM_0, NULL ) );
// enable dac outputs
ESP_ERROR_CHECK( i2s_set_dac_mode( I2S_DAC_CHANNEL_BOTH_EN ) );
// I2S log results:
//-----------------
// I (325) I2S: DMA Malloc info, datalen=blocksize=256, dma_buf_count=8
// I (345) I2S: APLL: Req RATE: 48000, real rate: 23999.980, BITS: 16, CLKM: 1, BCK_M: 8, MCLK: 6143995.000, SCLK: 767999.375000, diva: 1, divb: 0
// memory for i2s write:
//----------------------
// 64 samples = 128 bytes at 16bit
// 8 buffers = 1024 bytes ( 128 x 8 )
// 2 channels = 2048 bytes ( 1024 x 2 )
int outBytes = 2048;
// allocate output buffer memory
uint8_t* outBuf = ( uint8_t* )calloc( outBytes, sizeof( uint8_t ) );
// make spikes
outBuf[ 0 ] = 255;
outBuf[ 1 ] = 255;
outBuf[ 2 ] = 255;
outBuf[ 3 ] = 255;
// i2c bytes-written variable
size_t bytesOut;
// output the buffer
while( true )
{
ESP_ERROR_CHECK( i2s_write( I2S_NUM_0, outBuf, outBytes, &bytesOut, portMAX_DELAY ) );
// this results in silence; nothing on either pin 25 or 26; nothing on the scope.
// ESP_ERROR_CHECK reports nothing
}
}