From beda956acc5812f7352f538e45848b73fe04a633 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Mon, 15 Jul 2024 10:19:47 +0300 Subject: [PATCH] examples: Add DAC loop mode example. --- examples/Advanced/DAC_Loop/Dac_Loop.ino | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/Advanced/DAC_Loop/Dac_Loop.ino diff --git a/examples/Advanced/DAC_Loop/Dac_Loop.ino b/examples/Advanced/DAC_Loop/Dac_Loop.ino new file mode 100644 index 0000000..27556ee --- /dev/null +++ b/examples/Advanced/DAC_Loop/Dac_Loop.ino @@ -0,0 +1,41 @@ +// This examples shows how to use the DAC in loop mode. In loop mode the +// DAC starts automatically after all buffers are filled, and continuously +// cycle through over all buffers. +#include + +AdvancedDAC dac1(A12); + +void setup() { + Serial.begin(9600); + + while (!Serial) { + + } + + // Start DAC in loop mode. + if (!dac1.begin(AN_RESOLUTION_12, 16000, 32, 16, true)) { + Serial.println("Failed to start DAC1 !"); + while (1); + } + + // Write all buffers. + uint16_t sample = 0; + while (dac1.available()) { + // Get a free buffer for writing. + SampleBuffer buf = dac1.dequeue(); + + // Write data to buffer. + for (int i=0; i