The SAMD51 DAC is supposed to do 1M conversions/second. What exactly do you need to do to actually achieve that, or anything close to that?
the Clock should be set to 12MHz, and I have a loop: while (1) {
for (int i = 0; i < 4096; i += 1) { DAC->DATA[0].reg = i; while (!DAC->STATUS.bit.EOC0) // wait for conversion ; } }
So 4096 steps, at 24 clocks for each conversion. Inconsequential amount of looping code (at 120MHz), so it should be totally timed by the DAC itself, and should give me a waveform with a frequency of about 122Hz, right? (12e6/(3096*24))
I'm getting a nice sawtooth at about 12Hz; 1/10th of expected frequency!
But even if that was "working", it would only be doing 500k conversions/s (24 clocks at 12MHz.) It says in the datasheet that I can load a new DATA value after only 12 clocks, but ... I don't see any status bits that would tell me when those 12 clocks have elapsed?
There's a double buffer, but I can't see how get it to be used without using the event system? Is that the solution - you MUST use the event system to have the DAC trigger automatic loads from the buffered value? And I could check... interrupt bits (even if they're not enabled) to see if I can put new data in the buffered value? It just seems ... weird; like a lot of info that should be status bits just isn't present.
The Datasheet has a READY status bit for each DAC, but doesn't really describe what it means. It says "startup time has elapsed", which elsewhere is described as an initialization thing, rather than a between-coversions thing...
Most of the samples of other code I've seen online are for providing slow-changing outputs :-(