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.

TLV320AIC3204: Dynamic configuration of Biquad filter parameters is incorrect

Part Number: TLV320AIC3204

Dears:

    TLV320AIC3204 failed to configure Biquad filter parameters. How to dynamically generate parameters and write configurations?

    The customer used the C language program in the attached reference to write the parameters and found that the center frequency and gain of EQ were not correct.

     TLV320AIC3xxx滤波器的设置与实时调节.pdf

  • Dears:

       the c code as below, could you help to view and give some advise,  that the center frequency and gain of EQ were not correct, thank you!

    #include <stdio.h>
    #include <math.h>
    int main(int argc, char **argv){
    double res = 8388607; /* 这是一个常量: (2^(B-1)–1); 24位系数: 8388607, 16位: 32767 */
    double dBVal = 3; /* 增益 */
    double SRVal = 48000; /* 采样率 */
    double F0Val = 300; /* 频点 */
    double BWVal = 100; /* 带宽 */
    double A, omega, sn, cs, alpha; /* 中间量,S域到Z域双线性变换使用 */
    double a0, a1, a2, b0, b1, b2; /* 系数,计算用中间量 */
    double absMax = 0; /* 将b0, b1, b2转为小数时使用 */
    int N0, N1, N2, D1, D2; /* 保存计算的系数结果 */
    A = pow(10, (dBVal)/40);
    omega = 2 * M_PI * (F0Val)/(SRVal);
    sn = sin(omega);
    cs = cos(omega);
    alpha = A*sn/(2*F0Val/BWVal); /* 对于Peak EQ, Q = Q/A */
    b0 = 1 + (alpha*A); /* 这里开始根据S域到Z域的映射计算Z域的系数 */
    b1 = -1 * cs; /* 这里在转换的时候本应当乘以-2, 但是CODEC内部已经乘以2,所以这里只能乘以1 */
    b2 = 1 - (alpha*A);
    a0 = 1 + (alpha/A);
    a1 = -1 * cs; /* 同上,这里本应乘以-2 */
    a2 = 1 - (alpha/A);
    b0 /= a0; /* 这里开始将a0变换为1 */
    if(fabs(b0) > absMax) absMax = fabs(b0); /* 获取b0, b1, b2的最大绝对值 */
    b1 /= a0;
    if(fabs(b1) > absMax) absMax = fabs(b1);
    b2 /= a0;
    if(fabs(b2) > absMax) absMax = fabs(b2);
    a1 /= (-1*a0); /* a1, a2乘以-1是因为CODEC滤波器的设计,参见第一章的逻辑方框图 */
    a2 /= (-1*a0);
    if(absMax > 1.0) { /* 确保b0, b1, b2为纯小数 */
    b0 /= absMax;
    b1 /= absMax;
    b2 /= absMax;
    }
    /* 转换为整数并打印结果。在显示的时候,因为最高位是符号位,所以如果超出位宽24/16位则需要去掉纯符号位,比如FF81AA09实际数
    值取0x81AA09就是用于写到CODEC的系数数值 */
    N0 = floor(b0*res);
    N1 = floor(b1*res);
    N2 = floor(b2*res);
    D1 = floor(a1*res);
    D2 = floor(a2*res);
    printf("N0: %04X, N1: %04X, N2:%04X\r\nD1: %04X, D2: %04X\r\n", N0, N1, N2, D1, D2);
    return 0;
    }

  • The Customer C code as attachment.

    aic3204_eq.cpp

  • Did you crosscheck your register data if it's matching what you have programmed and where do you get the coefficient?

    Try to change the coefficient manually first and not during runtime to ensure you are configuring the device correctly from your system.

    Once that's confirm then you can refer the apps. note I attached above for changing coefficients at runtime.