XMEGA AU D/A output

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know nothing about the specifics you've mentioned but for a non ideal fix, I think you should be able to include a digitally controlled analog switch for the audio output line. Start that switch after some time (say a couple of seconds) to avoid that Pop! 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also suffered from the same thing.
Before enabling output, unless converting operation is performed with data 0, output seems to be undefined.
Please try the following initialization code.

    DACB.CTRLA = DAC_ENABLE_bm;
    DACB.CTRLB = DAC_CHSEL_SINGLE_gc;
    DACB.CTRLC = DAC_REFSEL_AVCC_gc | DAC_LEFTADJ_bm;
    DACB.CH0DATA = 0;

    DACB.CTRLA |= DAC_CH0EN_bm;

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good thoughts on the software setup.

 

What is your hardware?

The DAC isn't a strong driver.

Are you feeding a low pass filter and an audio amp?

 

Does the audio amp have a Mute pin that you could control during the startup phase?

 

Recall hardware wise, the DAC is DC coupled, its output goes from 0 to Vcc volts.

 

A small audio amp chip is likely AC coupled, and the "0" point is Vcc/2.

 

Classically, the DAC's Full Scale/2 will be about Vcc/2, and "match" the audio input's zero signal state.

 

Any wide, sudden, voltage swing will be fed through the system and come out as noise on start up.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to drive a speaker directly then you can use a couple of PWM channels to create a kind of class D amp. It drives a small speaker well enough, or you can make a little FET based push/pull driver to get more volume.

 

https://github.com/kuro68k/melod...

https://github.com/kuro68k/melod...