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.

CC2640R2F: PDMCC26XX Drivers

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640,

Hi TI,

* Reference code: “C:\ti\simplelink_cc2640r2_sdk_ble_example_pack_1_30_00_27\examples\rtos\CC2640R2RC\bleapps\hid_adv_remote”.

 

In simplelink\ble_sdk_2_02_00_31 (for CC2640), we have access to the uncompressed audio data from the digital mic (stored in array ‘tempPcmBuf[]’, below):

   [PDMCC26XX.c, Ln#601]:

   /* Decimate PDM data to PCM, result is stored in tempPcmBuf */

   pdm2pcm16k(bufferRequest.bufferIn, decimationState, object->decimationFilter, (int16_t *)&tempPcmBuf);

 

But ‘PDMCC26XX.c’ is no longer found in simplelink_cc2640r2_sdk_ble_example_pack_1_30_00_27 sample code (for CC2640R2F) !

Inside [hid_adv_remote.c] ‘HIDAdvRemote_processPdmData()’ function, we can only get compressed audio data which is stored in ‘bufferRequest.buffer’.

 

[Q1]: How to get access to the uncompressed audio data (from digital mic) in simplelink_cc2640r2_sdk_ble_example_pack_1_30_00_27 sample code (for CC2640R2F) ?

 

 

The ‘PDMCC26XX_Params’ in the same (above-said) reference code is used to configure Knowles digital mic used in CC2650RC.

If use other type/brand of digital mic, will need to set different setting for gain, filter roll off frequency, etc.

For the digital gain we can use other value than “micGain = PDMCC26XX_GAIN_18”.

[Q2]: Please advise, how to configure the filter roll off frequency ?

 

Thank you in advance.

  • Hi,

    The App pack is still using the TI-RTOS comes with CC2640r2_sdk_1_30_00_25.
    You can still find the PDM driver source code here : C:\ti\simplelink_cc2640r2_sdk_1_30_00_25\source\ti\drivers\pdm.
  • Hi,

    The decimation filter is not specific to the Knowles microphone. It was designed based on simulated PDM stream @1.024MHz, not taking into account the specific response of the microphone. This response is not only dependent on the microphone itself, but also the mechanics of the complete design. Thus, we made it possible to add an additional filter that operates @16kHz. There are three examples in the code already, they simply have to be uncommented.

    static const int32_t PDMCC26XX_aBqCoeffs[] = {
    //--v-- Adjust overall gain by changing this coefficient
    331, 0, -1024, -1356, 342, // DC-notch, halfband LP filter (@32 kHz)
    200, 789, 934, -994, 508,
    538, 381, 944, -519, 722,
    732, 124, 987, -386, 886,
    763, 11, 1014, -386, 886,
    0, // Terminate first filter
    // Insert optional second filter here (@16 kHz). Some examples:
    //1147,-1516, 522, -1699, 708, // +5dB peak filter (F0=500 Hz, BW=3 octaves)
    //1313, -565, -6, -725, 281, // +5dB peak filter (F0=2.5 kHz, BW=2 octaves)
    //1335, 532, -66, 694, 225, // +5dB peak filter (F0=5.5 kHz, BW=1 octave)
    0, // Terminate second filter
    };

    Following is a Matlab script that can help you calculate coeffiecients for your filter:

    %Design 2nd order IIR-filter (biquad) that implements a peak/notch
    % G - gain in dB
    % BW - bandwidth in octaves
    % F0 - Peak/notch frequency in Hz
    % Fs - Sample rate in Hz

    Fs = 16000
    Kroot = 10^(G/40);

    omega0 = 2*pi*F0./Fs;
    lambda = sinh(log(2)/2*BW*omega0/sin(omega0))*sin(omega0);
    b = [1+lambda*Kroot -2*cos(omega0) 1-lambda*Kroot]./(1+lambda/Kroot);
    a = [1 b(2) (1-lambda/Kroot)./(1+lambda/Kroot)];
    pdm2pcm16k_coeffs = round(1024*[b(1) b(2)./b(1) b(3)./b(1) a(2) a(3)]);

     

  • Hi Torbjorn,

     

    Is it possible for you to provide us more details on the following example quoted?

     

    Could you help provide us more details on why “1147,-1516, 522, -1699, 708,”is a peak filter with f0-500Hz, BW=3 octaves and with +5dB boost.

     

    //1147,-1516, 522, -1699, 708, // +5dB peak filter (F0=500 Hz, BW=3 octaves)

    What’s the meaning for each of the 5 coefficients.

     

    In other words, after checking FR, what kind of filter is needed to add, (F0, bandwidth, Gain/Attenuation)

     

    Can you also provide some guide on how to convert it to the 5 coefficients?

     

    Thanks,

    Christina

  • Hi Christina,

    The coefficients are simply a result of running the matlab script for a 2nd order IIR-filter that implements a peak/notch with the desired parameters. If you don't have matlab you can use for example https://octave-online.net/

    For the parameters:
    G = 5;
    BW = 3;
    F0 = 500;
    Fs = 16000;

    The output from pdm2pcm16k_coeffs will give exactly 1147,-1516, 522, -1699, 708.

    Kroot = 10^(G/40);
    omega0 = 2*pi*F0./Fs;
    lambda = sinh(log(2)/2*BW*omega0/sin(omega0))*sin(omega0);
    b = [1+lambda*Kroot -2*cos(omega0) 1-lambda*Kroot]./(1+lambda/Kroot);
    a = [1 b(2) (1-lambda/Kroot)./(1+lambda/Kroot)];
    pdm2pcm16k_coeffs = round(1024*[b(1) b(2)./b(1) b(3)./b(1) a(2) a(3)]);

    What do you mean by how to convert it to the 5 coefficients?

    Regards,

    Klas
  • Christina,

    If you want to know more about the math behind the filter, you can look up "Digital biquad filter". The "a" and "b" parameters can be seen in the transfer function H(z).

    Regards,

    Klas
  • Hi Klas,

    Instead of using Matlab, can we use TIBQ as well? Would TIBQ below generate those coefficients, it maybe different format.

    If it’s possible, my customer is planning to use TIBQ to get the register value and fill into the FW.

    cid:image001.jpg@01D34289.C4950690

    Best Regards,

    Christina Lim

  • HI,

    We tried using the matlab and Biqual calculator and had difficulty correlating the 2 results. Can anyone help?

    Below is Matlab result:

    //1147,-1516, 522, -1699, 708, // +5dB peak filter (F0=500 Hz, BW=3 octaves)

    Below is the Biquad calculator result:

     

    Text "* Sample Rate = 16000"

    Text "* Filter 1 EQ 500 Hz Fc 5.0 dB 3 Hz BW"

     

    Text "* BQ: H(z) = (N0 + 2*N1/z + N2/(z2)) / (32768 - 2*D1/z - D2/(z2))"

    Text "* Filter Coefficients in format N0, N1, N2, D1, D2"

     

    Text "* 1O: H(z) = (N0 + N1/z) / (32768 - D1/z)"

    Text "* Filter Coefficients in format N0, N1, D1"

     

    Text "* Filter 1 BQ "

    0x7FFF

    0x8299

    0x7FBA

    0x7D76

    0x8028

     

    Thanks,

    Christina

  • Hi Christina,

    I'm not familiar with TIBQ, but i've been using some online biqual calculators and compared them to the matlab script. I can confirm the results are not equal to what the matlab script is outputting. I've been talking to the author of the matlab script, and this can be because of a couple of different reasons:

    - normalized result.

    - rounding differences.

    - the actual math is not exactly the same, hence the result will be only similar, but not exactly the same.

    I think the best idea is to try both scripts and decide depending on performance.

    Regards,

    Klas

  • Hi Klas,

    Thanks so much for your information!

    May I know if there is any HPF and LPF matlab script that customer can use for further filtering?

    Thanks,

    Christina