Waveform generation_DAC_faster speed

Hi all,

I'm lately playing with the simple waveform generation example in Arduino Due as shown in the following link

I found that the processing time for the following code, which is basically two analogWrite operation, is 10us, i.e., 840 clock cycles.

void loop() {
analogWrite(DAC0, waveformsTable[wave0]); // write the selected waveform on DAC0
_ analogWrite(DAC1, waveformsTable[wave1]); // write the selected waveform on DAC1_
* i++;*
* if(i == maxSamplesNum) // Reset the counter to repeat the wave*
* i = 0;*
}
Is there any other programming approach to make it faster? Thanks.

Yes, you can use a DMA method for the DAC output.
I am currently working on a project using this approach to display a clock on a vector tube.
I used the DUE Audio player library as a basis for my code. See Audio - Arduino Reference
It works well and can achieve much faster and smoother output rates.

You can use a combination of a timer interrupt and some low level code. You can write to the 2 dacs at the same time using the word transfer mode in combination with the tag mode.