The DAC works fine on an Arduino Uno with sample sketch to produce a sine wave, but I wanted to change the frequency. The only way I have found to do this is to use the setClock function, however it can give odd results:
between 30500 (1.519Hz) and 700000 (18.83Hz) it changes the frequency in a fairly linear way, but below 30500 it is inconsistent and at 30200 it goes completely mad.
Is there a better way to change the frequency of the sine curve in the “MCP4725 Digital to Analog Converter Hookup Guide” sample sketch?
The Sparkfun sample sketch for the DAC has an array of 512 points, y values only, no time or angle values, so is completely dependent on the speed of the Wire.write command. That’s why changing the clock speed also changes the frequency. Because the write command takes a finite amount of time. Presumably an array with fewer points would give a higher frequency, but also a more notchy sine wave. I have used a formula to calculate the sine values but I think the lookup table is faster.