This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320AIC3104 "record-only" mode (register configuration)

Other Parts Discussed in Thread: TLV320AIC3204

Hi everybody,

I am a little lost and need your help !

Here is the problem:

I need to use the embedded "Digital audio for record Path" of the codec (cf datasheet P.28).

Enabling the path is not a problem, as it is well described.

But what I want is to use this very function:

which is shown in the "TLV320AIC3104EVM and TLV320AIC3104EVM-PDK User's Guide", that you can find here:

http://www.ti.com/lit/sg/slau218a/slau218a.pdf

Actually it is a screenshot taken from the GUI software which allows to control the codec from a PC with the evaluation kit. My kit does not work anymore, I do not know why, tried to fix it but lost one day which is to much at this time.

It is a shame because I wanted to trace registers used in the log window available in this software to set the EQ filter.

So my question is simple:

As I can not find any "Gain", "Bandwidth" at "FC" fields int the registers shown in the datasheet matching this EQ register, is there a way to program it anyway ? I mean according to the picture above, if I want to set "gain = 3dB", "BW=300Hz" and "FC=1000Hz", what are the corresponding I²C packet to send ?

Thank you very much in advance for your help !!

F.

  • Hi,

    We have a stand alone program that can be used to calculate the coefficients here:

    http://www.ti.com/tool/coefficient-calc?keyMatch=biquad%20coefficient%20calculator&tisearch=Search-EN

    once you have the coefficients that you want, you can load them to the desired effects filter on Page 1 of the register map.

    Best Regards,

    dave

  • Hello and thank you for this fast answer Dave.


    I took a look at your soft and it is interesting.

    But I think that I need to process the coeff myself, as I plan to set Frequency, Gain and Bandwith from a web interface.

    User won't be familiar with coeffs, but will be with frequency gain and BW.

    I therefore cannot use this option.

    I managed to make my board work so I am watching at the logs.

    I think the only solution is to process the coeffs from the web interface (user entry) and send them to the AIC3104.

    Can you confirm that ?

    (Codec is set through a microcontroller, running a light webserver)

    Thank you by advance,

    F.

  • You could either use the same formulas we are using to calculate the coefficients or you could create a table with some choices that have already been calculated. These are just standard biquad filters.

    Best Regards,

    dave

  • Hi Dave,

    Yes, I will choose this option of pre-calculated coeffs.

    Thank you !

    By the way,  I found the Matlab scripts matching the coeffs calculus on the SLAA447 in the annexes.

    For those interested, this can be found here: http://www.ti.com/lit/an/slaa447/slaa447.pdf

    Thank for your help,

    Fxois

  • Hi,

    Would you please tell me how to calculate the coefficients for the adaptive filters of TLV320AIC3204? I refered to document SLAA447 on page12 C.1 MATLAB script and programmed in Delphi on my PC, but I can not achieve the correct register values of coefficients, because I compared the values generated by my PC program and the ones generated by calculator tool from TI website, they are different. Greate appreciate if you can give me the help. Any documents please send them to my mail box:

    helloaxin@126.com

    Thanks.

  • Here is the delphi code:


    const
    NB = 24;//number of bits

    Type
    TBiquadFilterRegister = record
    valMSB:Byte;
    valMID:Byte;
    valLSB:Byte;
    end;


    {
    fs, fc: Hz
    gain: dB
    q: integer
    }
    procedure TForm1.GenerateN012D12(fs, fc, gain, q: Integer; var n0, n1, n2,
    d1, d2: TBiquadFilterRegister);

    procedure ConvertToHEX( val:Integer; var bfr:TBiquadFilterRegister );
    var
    v:Integer;
    begin
    if val >= 0 then v:=val
    else v := Floor(Power(2,NB))-1 - Abs(val) +1; // 2’s compliment , 求NB进制负数的二补数

    //I2C write sequence: valMSB, valMID, valLSB
    bfr.valMSB := (v shr 16) and $FF;//MSB first
    bfr.valMID := (v shr 8) and $FF;//medium second
    bfr.valLSB := v and $FF;//LSB last
    end;

    var
    w0, cosW, sinW, A, alpha:Real;
    b0, b1, b2, a0, a1, a2:Real;
    B0_, B1_, B2_, A1_, A2_:Real;
    Mx:Real;
    B0_new, B1_new, B2_new:Real;
    Range:Real;
    N0_, N1_, N2_, D1_, D2_:Integer;
    begin
    w0 := 2*Pi*fc/fs;
    cosW := cos(w0);
    sinW := sin(w0);
    A := Power(10,gain/40);
    alpha := sinW/(2*q*A);

    b0 := Power(10,gain/20)*(1+alpha*A);
    b1 := Power(10,gain/20)*(-2*cos(w0));
    b2 := Power(10,gain/20)*(1-alpha*A);
    a0 := 1+(alpha/A);
    a1 := -2*cos(w0);
    a2 := 1-(alpha/A);

    B0_ := b0/a0;
    B1_ := b1/(2*a0);
    B2_ := b2/a0;
    A1_ := a1/(-2*a0);
    A2_ := a2/(-a0);

    Mx := Max(Abs(B0_), Max(Abs(B1_),Abs(B2_)));

    if Mx > 1 then
    begin
    B0_new := B0_/Mx;
    B1_new := B1_/Mx;
    B2_new := B2_/Mx;
    end
    else
    begin
    B0_new := B0_;
    B1_new := B1_;
    B2_new := B2_;
    end;

    Range := Power(2,NB-1)-1;

    N0_ := Floor(B0_new*Range);
    N1_ := Floor(B1_new*Range);
    N2_ := Floor(B2_new*Range);
    D1_ := Floor(A1*Range);
    D2_ := Floor(A2*Range);
    ConvertToHEX(N0_,n0);
    ConvertToHEX(N1_,n1);
    ConvertToHEX(N2_,n2);
    ConvertToHEX(D1_,d1);
    ConvertToHEX(D2_,d2);
    end;

    function TForm1.SetFilterCoefficient(BandIdx: Integer): Boolean;
    var
    fs, fc, gain, q: Integer;
    n0, n1, n2, d1, d2: TBiquadFilterRegister;
    sl:TStringList;
    CH_L_RegBase, CH_R_RegBase:Integer;
    EQ_VAL, EQ_L, EQ_R:String;
    begin
    fs := 48000;//sample freqency: 48khz
    try
    case BandIdx of
    1:
    begin
    fc := StrToInt(edtFC1.Text);
    q := tbQ1.Position;
    gain := -tbGain1.Position;
    end;
    2:
    begin
    fc := StrToInt(edtFC2.Text);
    q := tbQ2.Position;
    gain := -tbGain2.Position;
    end;
    3:
    begin
    fc := StrToInt(edtFC3.Text);
    q := tbQ3.Position;
    gain := -tbGain3.Position;
    end;
    4:
    begin
    fc := StrToInt(edtFC4.Text);
    q := tbQ4.Position;
    gain := -tbGain4.Position;
    end;
    5:
    begin
    fc := StrToInt(edtFC5.Text);
    q := tbQ5.Position;
    gain := -tbGain5.Position;
    end;
    end;
    except
    MessageDlg('fc(Hz) setting error!',mtError,[mbOK],0);
    Exit;
    end;
    GenerateN012D12(fs,fc,gain,q,n0,n1,n2,d1,d2);

    CH_L_RegBase:=32+20*(BandIdx-1);
    CH_R_RegBase:=40+20*(BandIdx-1);
    EQ_VAL :=
    IntToHex(n0.valMSB,2)+', '+IntToHex(n0.valMID,2)+', '+IntToHex(n0.valLSB,2)+', '+'00, '+
    IntToHex(n1.valMSB,2)+', '+IntToHex(n1.valMID,2)+', '+IntToHex(n1.valLSB,2)+', '+'00, '+
    IntToHex(n2.valMSB,2)+', '+IntToHex(n2.valMID,2)+', '+IntToHex(n2.valLSB,2)+', '+'00, '+
    IntToHex(d1.valMSB,2)+', '+IntToHex(d1.valMID,2)+', '+IntToHex(d1.valLSB,2)+', '+'00, '+
    IntToHex(d2.valMSB,2)+', '+IntToHex(d2.valMID,2)+', '+IntToHex(d2.valLSB,2)+', '+'00';

    EQ_L := '30, '+IntToHex(CH_L_RegBase,2)+', '+ EQ_VAL +', w';
    EQ_R := '30, '+IntToHex(CH_R_RegBase,2)+', '+ EQ_VAL +', w';

    sl := TStringList.Create;
    try
    sl.Add('30,00,2C,w');
    sl.Add(EQ_L);
    sl.Add('30,00,2D,w');
    sl.Add(EQ_R);
    //********************************
    sl.Add('30,00,2C,05,w');
    //;f,30,01,xxxxx1x0
    //delay,100
    //********************************
    sl.Add('30,00,2C,w');
    sl.Add(EQ_L);
    sl.Add('30,00,2D,w');
    sl.Add(EQ_R);

    mmoScript.Clear;
    mmoScript.Lines.Assign(sl);
    btnActionScriptClick(btnActionScript);
    finally
    sl.Free;
    end;
    end;

    procedure TForm1.tbGain1Change(Sender: TObject);
    begin
    SetFilterCoefficient( (Sender as TTrackBar).Tag );
    end;