I am using the D/A output (DACB.CH0) to drive an audio out line from a wav input file. Everything works fine except that on startup there is a huge pop as the D/A is enabled. I have tried everything I can think of to make the output start at 0V and ramp up to half scale prior to starting the audio processing, but no matter what value is loaded into the data registers, it still immediately jumps to half scale on enabling:
// this is part if the initialization routine:
DACB.CTRLC=0x09; //set left justify, Vref=Vcc (output is 0 here after startup)
DACB.CH0DATAL=0x00; //still 0
DACB.CH0DATAH=0x00; //still 0
DACB.CH0DATAL=0x00; //still 0, do twice to try to clear TEMP register????
DACB.CH0DATAH=0x00; //still 0
DACB.CTRLA=0x05; //enable DAC and CH0 out (immediately jumps to 1.6V here, big pop)
.....
dat=0;
for(i=0; i<128; i++) { //try to ramp up to avoid pop
DACB.CH0DATAH=dat;
dat++;
}
So with 0 in both data registers why does it jump on enable? As usual I seem to be missing something obvious, any suggestions? The manual says the TEMP register needs to be cleared for 8 bit left justified operation but doesn't mention how to clear it:
When left adjusted data is selected, it is possible to do 8-bit conversions by writing only to the
high byte of CHnDATA, i.e., CHnDATAH. The TEMP register should be initialized to zero if only
8-bit conversion mode is used.
Thanks,
Harry