diff options
| -rw-r--r-- | ports/esp32/machine_i2s.c | 1 | ||||
| -rw-r--r-- | ports/stm32/machine_i2s.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/ports/esp32/machine_i2s.c b/ports/esp32/machine_i2s.c index dc583e8e9..390b01e5e 100644 --- a/ports/esp32/machine_i2s.c +++ b/ports/esp32/machine_i2s.c @@ -448,6 +448,7 @@ STATIC void machine_i2s_init_helper(machine_i2s_obj_t *self, size_t n_pos_args, i2s_config.dma_buf_count = get_dma_buf_count(mode, bits, format, self->ibuf); i2s_config.dma_buf_len = DMA_BUF_LEN_IN_I2S_FRAMES; i2s_config.use_apll = false; + i2s_config.tx_desc_auto_clear = true; // I2S queue size equals the number of DMA buffers check_esp_err(i2s_driver_install(self->port, &i2s_config, i2s_config.dma_buf_count, &self->i2s_event_queue)); diff --git a/ports/stm32/machine_i2s.c b/ports/stm32/machine_i2s.c index 32167cf4e..266dd45e8 100644 --- a/ports/stm32/machine_i2s.c +++ b/ports/stm32/machine_i2s.c @@ -509,6 +509,9 @@ STATIC void feed_dma(machine_i2s_obj_t *self, ping_pong_t dma_ping_pong) { if (self->bits == 32) { reformat_32_bit_samples((int32_t *)dma_buffer_p, SIZEOF_HALF_DMA_BUFFER_IN_BYTES / (sizeof(uint32_t))); } + } else { + // underflow. clear buffer to transmit "silence" on the I2S bus + memset(dma_buffer_p, 0, SIZEOF_HALF_DMA_BUFFER_IN_BYTES); } // flush cache to RAM so DMA can read the sample data |
