Guys,
Got my first code going with a DAC.
Is there anything more I can do to speed this up a little?
Driving 4 of these with 2 outputs each.
Not going for audio quality here, will be remoting the voltage level of some pots.
That would be confirmed by the screenshot of the logic analyzer. It takes 10.5 uS to send out one 16-bit value. That sounds about right as I reckon a single SPI byte to be about 3 uS, plus turning SS on and off. So that sounds OK, you can't do much better than that. Then another 5.5 uS for adding, and the loop etc. Total of 16 uS.
Now you are doing 4096 values up and 4096 values down to get one cycle. So 8192 * 16 uS = 131072 uS.
So your frequency is going to be 1 / 0.131072 which is 7.629 Hz, which exactly agrees with the observed frequency.
To speed it up? You could add more each time (eg. add 2 on the way up, subtract 2 on the way down).
But for remoting pots, well responding within 1/7th of a second is OK isn't it? But as I said, if you want faster, just add more each time. Of course, if you just want to jump from a setting of 500 to a setting of 1000 (with no intermediate steps) then that will take you 16 uS.
There's not much point. Even if you double the speed you only get 14 Hz. And the limiting factors now are the speed with which you can go through the loop.
Which part? Are you surprised it worked? The datasheet says 16 MHz clock support (in the bragging part at the start). With your change we are using a 8 MHz clock. So it's within spec.
5.0 SERIAL INTERFACE
5.1 Overview
Refer to Figure 1-1 and SPI Timing Specifications Table for detailed input and output timing specifications for both Mode 0,0 and Mode 1,1 operation.
Off to Figure 1-1... The timing diagram includes the SCK signal with the high level labeled tHI and the low level labeled tLO. In the table above the diagram tHI and tLO both have a minimum value of 15 ns. 1 / ((15+15) * 10e-9) = 3,333,333 MHz.
I realize chip vendors publish guaranteed numbers but, assuming I'm reading the datasheet correctly, 8 MHz is more than twice the maximum bitrate.
15ns * 2 would put max frequency at 33.3 Mhz. For a 20Mhz chip, min t-low and t-high at 15ns seems a reasonable specification to allow for rise and fall times. 8 Mhz should be just fine.