 // but rather a ringbuffer. There is an index to the currently used entry.
 //
 // DMA transfers can be triggered by the FIFO index being at 0 and
-// the FIFO watermark. This code uses these triggers to transfer 4 entries
-// at a time. The lower half of the FIFO (entries 0 - 3) is updated when
-// the FIFO index reaches 4 (the watermark), the upper half (entries 4 - 7)
+// the FIFO watermark. This code uses these triggers to transfer 8 entries
+// at a time. The lower half of the FIFO (entries 0 - 7) is updated when
+// the FIFO index reaches 11 (maximum - 4) (= the watermark), the upper half (entries 8 - 15)
 // is updated when the FIFO index wraps to 0.
 //
 // The FIFO DMA destination is set up using the DMA modulo feature,

static_assert(buffer.size() % 8 == 0, "Buffer size must be multiple of DAC buffer.");

void initBuffer() {
    for(size_t i = 0; i < buffer.size(); i += 4) {
        buffer[i+0] = 0;
        buffer[i+1] = 1000;
        buffer[i+2] = 2000;
        buffer[i+3] = 3000;
    }
}


        unsigned dac_out_idx_curr = DAC0_C2 >> 4;
        unsigned dac_val = ((aliased_uint16_vptr) &DAC0_DAT0L)[dac_out_idx_curr];
        interrupts();
        if(/*src_idx_prev == src_idx_curr &&*/ dac_out_idx_prev == dac_out_idx_curr) continue;
        src_idx_prev = src_idx_curr;
        dac_out_idx_prev = dac_out_idx_curr;
        if (!TRACE_VIEW)
          Serial.printf("DMA src idx: %4u   DMA dest idx: %4u   DAC out idx: %4u   DAC value: %4u\n",
                      src_idx_curr, dest_idx, dac_out_idx_curr, dac_val);
        else
          Serial.println(dac_val); // This allows to see the waveform in the tracer
    }
}

