That is very strange. It's going to take a little time to dig to the bottom of what's going on. In the meantime, I have a few ideas for 'quick fixes' so you aren't waiting on a full / proper fix:
1) Can you try placing a small delay between the two DAC updates:
writeDAC1(out);
delayNanoseconds(100);
writeDAC2(out);
delayNanoseconds(100);
2) If that doesn't work, try pre-calculating the DAC update values. Here's a sketch of how to change your code to do that
const uint precalcSize = PERIOD / DAC_UPDATE;
float data[precalcSize];
void setup() {
for (uint i=0; i<precalcSize; i++) {
time = i*DAC_UPDATE;
data[i] = cosPower(TRAP_TIME, 1, 8);
}
time = 0;
Timer.begin(updateDAC, DAC_UPDATE);
}
void updateDAC() {
if (time < PERIOD) {
//float out = cosPower(TRAP_TIME, 1, 8);
uint index = time / DAC_UPDATE;
float out = data[index];
writeDAC1(out);
writeDAC2(out);
time += DAC_UPDATE;
} else {
time = 0;
}
}
If neither of those work, please let me know.
Sorry for the bug and I appreciate your patience while we figure it and out and fix it.