SGTL5000 linein to adc to dac to HP signal path

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SGTL5000 linein to adc to dac to HP signal path

585 Views
AB_Dev
Contributor I

Hi,

I have a board that is still equipped with an SGTL5000.
A micro is connected to LineIn and the speaker to HeadphoneL/R.

The analogue path Mic -> LineIn -> Headphone works. There the
ADC/DAC & DAP is bypassed and I hear something (with initBasicConfig() & initAnalogAudioPath() )

Now I want to switch to LineIn -> ADC -> DAC -> Headphone (with with initBasicConfig() & initDigitalAudioPath() )
But I don't hear a peep (in the long run, the ADC is supposed to send via i2s to a
controller and from there via i2s to the DAC, but that would be the step next but one step)

If I deactivate the DAP completely and configure the ADC as input for the DAC, I should hear something, right?
I have set the DAC & ADC to unmute.
I tried to set the DAP to passthrough via DAP_EN because
I'm not sure if "When disabled, no audio passes through" applies otherwise?
But actually in
https://community.nxp.com/t5/Other-NXP-Products/Routing-ADC-gt-DAC-in-sgtl5000/m-p/699654 it is said that the DAP is completely optional (but in which case do I have to set it to passthrough then?
if ADC -> DAP -> DAC and I don't use the DAP at all what sense does that make? Or is that
only needed if use the DAP mixer)?

my mic is on LINEIN_L (pin14) and my speaker on HP_R (Pin2)

 

 

void SGTL5000::initBasicConfig(){
  writeRegister(CHIP_LINREG_CTRL_ADD, 0x006C);  // VDDA & VDDIO both over 3.1V
  writeRegister(CHIP_ANA_POWER_ADD, 0x77FF); 
  CHIP_REF_CTRL.VAG_VAL   = 0x1f;  // 1.575v
  CHIP_REF_CTRL.BIAS_CTRL = 0x00;  // nominal
  CHIP_REF_CTRL.SMALL_POP = 0x01;  // slow
  writeRegister(CHIP_REF_CTRL_ADD, CHIP_REF_CTRL.data);

  CHIP_LINE_OUT_CTRL.OUT_CURRENT = 0x03;  // 0,36mA
  CHIP_LINE_OUT_CTRL.LO_VAGCNTRL = 0x22;  // 1,65 V
  writeRegister(CHIP_LINE_OUT_CTRL_ADD, CHIP_LINE_OUT_CTRL.data);

  CHIP_MIC_CTRL.BIAS_RESISTOR = 0x01;  // 2kOhm
  CHIP_MIC_CTRL.BIAS_VOLT     = 0x03;  // 3.00V
  CHIP_MIC_CTRL.GAIN          = 0x02;  // 30dB
  writeRegister(CHIP_MIC_CTRL_ADD, CHIP_MIC_CTRL.data);

  writeRegister(CHIP_DIG_POWER_ADD, 0x0073);   // power up all digital stuff
  writeRegister(CHIP_SHORT_CTRL_ADD, 0x4446);  // allow up to 125mA
  writeRegister(CHIP_CLK_CTRL_ADD, 0x0000);      // 32k kHz, 256*Fs default values
  writeRegister(CHIP_I2S_CTRL_ADD, 0x0130);      // SCLK=32*Fs, 16bit, I2S format

}

void SGTL5000::initAnalogAudioPath()
{
  DAP_CONTROL.DAP_EN = 0x00;  // 
  DAP_CONTROL.MIX_EN = 0x00;  // dap mixer disable
  writeRegister(DAP_CONTROL_ADD, DAP_CONTROL.data);

  CHIP_ANA_CTRL.MUTE_ADC   = 0x01;           // 
  CHIP_ANA_CTRL.EN_ZCD_ADC = 0x01;           // adc zero cross detection enabled
  CHIP_ANA_CTRL.SELECT_ADC = 0x01;           // ADC input: line in
  CHIP_ANA_CTRL.MUTE_HP    = 0x00;           // unmute headphone
  CHIP_ANA_CTRL.EN_ZCD_HP  = 0x01;           // headphone zerocross detection enabled
  CHIP_ANA_CTRL.SELECT_HP  = 0x01;           // headphone input: line in
  CHIP_ANA_CTRL.MUTE_LO    = 0x01;           // mute line out
  writeRegister(CHIP_ANA_CTRL_ADD, CHIP_ANA_CTRL.data);  // enable zero cross detectors

}

void SGTL5000::initDigitalAudioPath(){
  DAP_CONTROL.MIX_EN = 0x00;   
  DAP_CONTROL.DAP_EN = 0x00;  
  writeRegister(DAP_CONTROL_ADD, DAP_CONTROL.data);

  CHIP_ANA_CTRL.MUTE_ADC   = 0x00;           // unmute ADC
  CHIP_ANA_CTRL.EN_ZCD_ADC = 0x01;           // adc zero cross detection enabled

  CHIP_ANA_CTRL.SELECT_ADC = 0x01;           // ADC input: line in
  CHIP_ANA_CTRL.MUTE_HP    = 0x00;           // unmute headphone
  CHIP_ANA_CTRL.EN_ZCD_HP  = 0x01;           // headphone zerocross detection enabled
  CHIP_ANA_CTRL.SELECT_HP  = 0x00;           // headphone input: DAC
  CHIP_ANA_CTRL.MUTE_LO    = 0x01;           // mute line out
  writeRegister(CHIP_ANA_CTRL_ADD, CHIP_ANA_CTRL.data);  // enable zero cross detectors

  CHIP_ADCDAC_CTRL.DAC_MUTE_RIGHT = 0x00; //unmute
  CHIP_ADCDAC_CTRL.DAC_MUTE_LEFT = 0x00;  //unmute
  writeRegister(CHIP_ADCDAC_CTRL_ADD, CHIP_ADCDAC_CTRL.data);
  

  // ROUTING
  CHIP_SSS_CTRL.DAC_SELECT = 0x00;  // Source for DAC: ADC
  writeRegister(CHIP_SSS_CTRL_ADD, CHIP_SSS_CTRL.data);
}

 

 

 

The essential lines for the digital path are actually

 

 

CHIP_SSS_CTRL.DAC_SELECT = 0x00; // Source for DAC: ADC
CHIP_ANA_CTRL.SELECT_HP = 0x00; // headphone input: DAC

 

 

Am I missing any settings? I have left the volumes untouched
untouched for the time being, as they were not set to 0.

thansk for help. I am really at a loss here

0 Kudos
5 Replies

414 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Do you follow SGTL5000 Initialization and Programming - Application Note where are listed basis for accessing registers, and initializing and configuring SGTL5000 out of reset?

There are examples about Writing a Register, Chip Powerup and Supply Configurations, Input/Output Routing, etc.

Best regards.

0 Kudos

525 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, I hope you are doing well.

I suggest you check the next thread that could help for your application:

Solved: SGTL5000 Routing LINEIN -> ADC -> DAP -> DAC -> HP... - NXP Community

Best regards.

 

445 Views
AB_Dev
Contributor I

this is my current setup code. i'm not sure if i powerup something wrong?
I'm totaly stuck. line_in to HP_out works like a charme, but as soon as i switch to adc ->(DAP) ->DAC -> HP_out   i hear nothing

VDD is 1,8V
VDDIO 3,3V
VDDA 3,3V

 writeRegister(CHIP_ANA_POWER_ADD, 0x4060);      // VDDD is externally driven with 1.8V
   writeRegister(CHIP_LINREG_CTRL_ADD, 0x006C);    // VDDA & VDDIO both over 3.1V
   //writeRegister(CHIP_ANA_POWER_ADD, 0x6AFF);  // power up: lineout, hp, adc, dac
 
  writeRegister(CHIP_REF_CTRL_ADD, 0x01F2);       // VAG=1.575, normal ramp, +12.5% bias current
  writeRegister(CHIP_LINE_OUT_CTRL_ADD, 0x0F22);  // LO_VAGCNTRL=1.65V, OUT_CURRENT=0.54mA
  writeRegister(CHIP_SHORT_CTRL_ADD, 0x7776);
  writeRegister(CHIP_ANA_POWER_ADD, 0x40FF);  // power up: lineout, hp, adc, dac
 
  writeRegister(CHIP_DIG_POWER_ADD, 0x0073);  // power up all digital stuff
  for (volatile uint32_t i = 0; i < 4000000; i++) {
  };
  writeRegister(CHIP_LINE_OUT_VOL_ADD, 0x1D1D);  // default approx 1.3 volts peak-to-peak
  writeRegister(CHIP_CLK_CTRL_ADD, 0x0000);      // 32k kHz, 256*Fs
  writeRegister(CHIP_I2S_CTRL_ADD, 0x0130);      // SCLK=32*Fs, 16bit, I2S format

  readRegister(CHIP_SSS_CTRL_ADD, CHIP_SSS_CTRL.data);
  CHIP_SSS_CTRL.DAP_SELECT = 0x0000;  // input: adc
  CHIP_SSS_CTRL.DAC_SELECT = 0x0003;  // input: dap
  writeRegister(CHIP_SSS_CTRL_ADD, CHIP_SSS_CTRL.data);

  // Select DAC as the input to HP_OUT
  readRegister(CHIP_ANA_CTRL_ADD, CHIP_ANA_CTRL.data);
  CHIP_ANA_CTRL.MUTE_ADC   = 0x0000;  //unmute
  CHIP_ANA_CTRL.SELECT_ADC = 0x0001;  //linein
  CHIP_ANA_CTRL.SELECT_HP  = 0x0000;  //dac
  CHIP_ANA_CTRL.MUTE_HP    = 0x0000;  //unmute
  CHIP_ANA_CTRL.MUTE_LO    = 0x0001; //mutelo
  writeRegister(CHIP_ANA_CTRL_ADD, CHIP_ANA_CTRL.data);

  readRegister(DAP_CONTROL_ADD, DAP_CONTROL.data);
  DAP_CONTROL.DAP_EN = 1;
  writeRegister(DAP_CONTROL_ADD, DAP_CONTROL.data);  // bit 0

  writeRegister(CHIP_ANA_ADC_CTRL_ADD, 0x00FF);
  writeRegister(CHIP_DAC_VOL_ADD, 0x3C3C);

  readRegister(CHIP_ADCDAC_CTRL_ADD, CHIP_ADCDAC_CTRL.data);
  CHIP_ADCDAC_CTRL.DAC_MUTE_LEFT  = 0x0000; //unmute
  CHIP_ADCDAC_CTRL.DAC_MUTE_RIGHT = 0x0000; //unmute
  writeRegister(CHIP_ADCDAC_CTRL_ADD, CHIP_ADCDAC_CTRL.data);

  CHIP_ANA_HP_CTRL.HP_VOL_LEFT  = 0x00;
  CHIP_ANA_HP_CTRL.HP_VOL_RIGHT = 0x00;
  writeRegister(CHIP_ANA_HP_CTRL_ADD, CHIP_ANA_HP_CTRL.data);

 

0 Kudos

491 Views
AB_Dev
Contributor I

i checked everything and still no luck.
i unmuted ADC&DAC
i unmuted dac left&right

i can read the id via i2c so my mclk is there and i2c is working (i get 0xA011 )

but still i hear absolutley nothing with the linein -> adc -> (DAP) -> DAC -> HP out route

i tried  ADC-> DAP(in passthrough with DAP_EN =1 ) -> DAC

i also tried DAP disabled and ADC as input to DAC but also no luck. i don't see what i'm doing wrong.
Analog linein -> HP-out still works fine

i checked with with a logic analyzer if somehow little/big endianess is a problem but to me this seems correct

AB_Dev_0-1693993067513.png

 

0 Kudos

551 Views
AB_Dev
Contributor I

hmm has nobody any input or some idea what i'm doing wrong?

0 Kudos