The Audio library uses the PDB to trigger a DMA transfer to the DAC output register. This is achieves low jitter when there is no other DMA traffic. However, other DMA transfers can delay the DAC transfer and result in jitter.
Here is sample code for DAC output using the FIFO and DMA. The FIFO has 16 entries, but only 8 are useful due to hardware limitations. After the first half of the FIFO is output (4 entries), it is updated with a DMA transfer. The same thing happens after the second half of the FIFO has been output.
Exact, jitter-free timing is achieved. The DAC takes samples from the FIFO at precise intervals, triggered by the PDB (it is not affected by DMA transfer jitter).
The code will work for DAC1, if references to DAC0 are replaced. DAC1 has its own DMA trigger, so linked DMA is not required when both DACs are used.
https://github.com/tni/teensy-samples/blob/master/dac_fifo_dma.ino
Here is sample code for DAC output using the FIFO and DMA. The FIFO has 16 entries, but only 8 are useful due to hardware limitations. After the first half of the FIFO is output (4 entries), it is updated with a DMA transfer. The same thing happens after the second half of the FIFO has been output.
Exact, jitter-free timing is achieved. The DAC takes samples from the FIFO at precise intervals, triggered by the PDB (it is not affected by DMA transfer jitter).
The code will work for DAC1, if references to DAC0 are replaced. DAC1 has its own DMA trigger, so linked DMA is not required when both DACs are used.
https://github.com/tni/teensy-samples/blob/master/dac_fifo_dma.ino