Skip to content

Commit 3d7c91c

Browse files
committed
ESP32 PWM Prescaler to 2
1 parent 94f4ae9 commit 3d7c91c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/AudioAnalog/AnalogAudioESP32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ class AnalogAudioStream : public AudioStreamX {
263263
LOGI("TX_MODE");
264264
if (i2s_set_pin(port_no, nullptr) != ESP_OK) LOGE("i2s_set_pin");
265265
if (i2s_set_dac_mode( I2S_DAC_CHANNEL_BOTH_EN) != ESP_OK) LOGE("i2s_set_dac_mode");
266+
if (i2s_set_sample_rates(port_no, cfg.sample_rate) != ESP_OK) LOGE("i2s_set_sample_rates");
266267
break;
267268

268269
default:

src/AudioPWM/PWMAudioESP32.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ class PWMAudioStreamESP32 : public PWMAudioStreamBase {
104104
LOGD(LOG_METHOD);
105105

106106
// Attach timer int at sample rate
107-
int prescale = 1;
107+
int prescale = 2;
108108
bool rising_edge = true;
109-
timer = timerBegin(audio_config.timer_id, prescale, rising_edge); // Timer at full 40Mhz, no prescaling
110-
uint32_t counter = 40000000 / audio_config.sample_rate;
109+
timer = timerBegin(audio_config.timer_id, prescale, rising_edge); // Timer at full 40Mhz, prescaling 2
110+
uint32_t counter = 20000000 / audio_config.sample_rate;
111111
LOGI("-> timer counter is %zu", counter);
112112
LOGD("-> timerAttachInterrupt");
113113
bool interrupt_edge_type = true;

0 commit comments

Comments
 (0)