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.

CC2640: PDMCC26XX drivers

Part Number: CC2640

Hello,

    PDMCC26XX driver is used or receiving audio chunks from microphone in sensortag_audio.c.  I have couple of questions about it.

    1-PDMCC26XX driver converts PDM modulated data to PCM encoded data. How could I find driver that converts PCM encoded audio to raw audio data(encoder source)? There are also hardware encoders of TI for this purpose. Do you suggest hardware or software encoding?

    2-PDMCC26XX driver seems it is designed for taking audio input. Could this module be used for also sending audio data over I2S bus(as output, for example when working with speakers)?

Regards.

Oytun

  • Hi,

    1. You can find the SW encoding source code when you download our BLE SDK 2.2.1(which comes with corresponding TI-RTOS) : C:\ti\tirtos_cc13xx_cc26xx_2_20_01_08\products\tidrivers_cc13xx_cc26xx_2_20_01_10\packages\ti\drivers\pdm\Codec1.c

    2. Yes, you can use the I2S module to output data to a speaker. We have a example ready for this implementation. You can find the example here :
    github.com/.../simple_peripheral_audio_transmitter.md

    You can find more information regarding our voice solution here : software-dl.ti.com/.../voice.html
  • Christin,

    Codec1.c source decodes and encodes "TI codec type 1" (IMA ADPCM) and raw audio data as written in doxygen comments in the header of this file. Is this true?
    I am trying to decode PCM encoded data(Audio data received from PDMCC26XX drivers). As I checked PCM and ADPCM are different codecs and Codec1.c source could be useless for my case. Is this correct?

    Regards.
    Oytun
  • Hi Oytun,

    In our implementation PCM are the raw uncompressed samples. These map "directly" to the ADC samples. Codec1.c is for compression/decompression of ADPCM (from/to PCM).

    It's a little confusing that coding/decoding and compression/decompression has the same short form "codec".

    PDMCC26XX driver can provide both compressed and non-compressed data. In the non-compressed case you would get PCM samples directly.

    "Codec1.c source decodes and encodes "TI codec type 1" (IMA ADPCM) and raw audio data" --> "Codec1.c source encodes raw audio data [PCM]" and "Codec1.c source decodes "TI codec type 1" (IMA ADPCM) [to PCM]"
  • Hi Torbjorn,

    I am trying to use "Codec1_decodeBuff(int16_t* dst, uint8_t* src, unsigned srcSize, int8_t *si, int16_t *pv)" function which is in Codec1.c source, for decoding an ima-adpcm encoded audio file. However I am not sure what will be the initial values of "step_index" and "predicted_value". Do you have any suggestion?

    Regards.
    Oytun
  • Hi Oytun,

    We start with 0, 0. It should match the choice on the encoding side.

  • Hi Torbjorn,

    I am trying to run PDMCC26XX drivers in simple peripheral example. They are working fine standalone actually, however I could not connect to the CC2640 over BLE when drivers are in use. Do you have any comment on this issue?

    Regards.
    Oytun
  • Hi,

    Please take a look at the github example simple_peripheral_audio_transmitter project, which is based on simple_peripheral and then we integrate the PDM driver into the project.
  • thank you for your help.

    If I use applyCompression, should I also use the functions in Codec1.c or the PDMCC26XX will automatically use them? 

  • PDM driver takes care of it. Note that you'll get meta data for the compressed frame in the meta section of the returned struct.

  • Thank you, I tried the PDMstream project in TI RTOS driver example, if I use the compression mode, is PCM buffer data still of the type uint16_t? Any other things different compared to the uncompression mode?
    One more question, it seems that every 2ms the driver generates 384 uncompressed PCM data and 384/4=96 compressed data, how did you derive that? Do these PCM data cover all of the data the PDM driver generates during the 2ms ?
    Thank you very much
  • Hi, I have the same question as Jason Lee60 do, how can I implement the compressed PCM data?
    I am new to here, thank you for your understanding
  • Hi Jason,

    Every 2ms one PDM block of data is processed (decimated into PCM). x number of these are packet into a frame. For the default compression, 6 of these are packed into a frame. That frame contains 96 bytes of data, or 192 samples. This comes from a (PCM) sampling rate of (almost) 16kHz. You get 384 bytes since each sample has 16 bit resolution.

    The data type for the compressed data is not a standard type, so no union was defined in the struct although it could have been for readability. Based on the protocol the receiver knows whether the data is compressed or not. Over the air it's just a stream of bytes anyway.
  • Thank you for your help.
    I was trying to extract PCM data from the PCM data buffer when compression applied, I tried both data type of uint8_t and uint16_t, but they both suffered severe distortions. Do you have examples or documents regrading to PCM data type in the compression mode(since the default is uncompressed)?
    P.S. Project hid_adv_remote seems doesn't show the data type
  • Hi Jason,

    You have to run it through the decompression routine. Please see Central Audio project for example code.

  • Thank you, I did as you instructed. I requested 16 PDM buffers(run PDMCC26XX_requestBuffer 16 times continously without stopping streaming), but I found the fact as the time increases, there many PCM data with the values larger than 65530. I don't know if I did someting run, should I stop the streaming after I request one PCM buffer?
  • Hi Jason,

    Your previous question was about how to decompress samples. Now you're talking about getting 16 consecutive PCM frames? I'm confused.. If you have still enabled compression then you are not getting PCM samples back from the bufferRequest(). Hence, there's no 16 bit data you can directly look at. You have to decompress it first to look at the PCM data.

  • I am sorry I didn't explain clearly . I followed ur instruction and the compressed PCM data works fine, but due to the application requirements we decided to try uncompressed mode as well. But the consecutive PCM data seems to have something wrong , that's what i am asking

    Thank you again for your kind help

  • Hi, I solved the problem myself, the problem was because I mishandled some var types, thank you for your help, can I ask u questions if I have problems?
  • Hi, in the sample project Central Audio project it seems that the receiver receives the audio data which has already been encoded at the side of transmitter, the transmitter uses encode function in Codec1.c, and the receiver decodes the received data. However, can I decode the audio data directly just after I request buffer(applyCompression enabled)?
  • Hi Jason,

    The answer is, in the same way. I do have to ask, if you want the samples uncompressed immediately, why do you compress them in the first place?

  • Thank you very much for your help, I apologized for the delayed response. I used to compress in order to save memory space, now the problem solved.

    I would  like to ask for another question, in the TI RTOS PDM driver sample project, it seems that I can't change parameters in the header files like PDM_BUFFER_SIZE_IN_BLOCKS and PDM_TASK_STACK_SIZE, but in the BLE demo project "prepherial audio transmitter"( not exact the same project name) I can change these parameters. There are both PDMCC26XX.h and PDMCC26XX.c files in the BLE demo project tree, I don't know if it's the reason. In the TI RTOS PDM sample driver project, the definitions of functions such as PDMCC26XX_init only shows

    extern void PDMCC26XX_init(PDMCC26XX_Handle handle);

    Should I add  PDMCC26XX.c in the TI RTOS sample project? I am new to your TI products, so I am a little confused about the way it works.

    Thank you again for your kindness help