Skip to content

Crackling sound on i2s with internal DAC since 2.0.10 #8467

Closed
@harbaum

Description

@harbaum

Board

ESP32 dev board

Device Description

DevKitC

Hardware Configuration

Speaker on GPIO25

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Linux and Windows

Flash frequency

40Mhz

PSRAM enabled

no

Upload speed

921000

Description

This demo sketch used to play a rectangle wave form on GPIO25 it works on 2.0.6 to 2.0.9

Since 2.0.10 sound is distorted and has a crackling noise overlaid. Oscilloscope shows short spikes in the rectangle signal.

Sketch

#include "driver/i2s.h"

unsigned short snd_buffer[64];

void setup() {
    static const i2s_config_t i2s_config = {
    .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
    .sample_rate = 24000,
    .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,

    .channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
    .intr_alloc_flags = 0,
    .dma_buf_count = 4,
    .dma_buf_len = 64,   // 64 samples
    .use_apll = true
  };
  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
  i2s_set_dac_mode(I2S_DAC_CHANNEL_RIGHT_EN);
}

void loop() {
  // generate square wave
  for(int i=0;i<32;i++)  snd_buffer[i] = 0x0000;
  for(int i=32;i<64;i++) snd_buffer[i] = 0x1000;

  size_t bytesOut = 0;
  i2s_write(I2S_NUM_0, snd_buffer, sizeof(snd_buffer), &bytesOut, 0);
  printf("BytesOut: %d\n", bytesOut);
}

Debug Message

Endless sequence of
BytesOut: 128
BytesOut: 0

No difference in output between 2.0.9 and 2.0.10

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions