This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need help with nRF52 I2S EasyDMA - RXD Buffer Pointer

Hi,

I'm trying to setup NRF52 with a microphone (ICS-43432) using I2S and easyDMA. I'm new to embedded software development, and would very much appreciate your help and patience.

My plan is to use just one (left) channel for receiving the data from the microphone and transmit it over BLE using the S132 stack.

From the code snippet in the I2S section of the product specification, I gather that the RX data pointer for easyDMA needs to be configured as follows:

NRF_I2S->RXD.PTR = my_rx_buf;

NRF_I2S->RXTXD.MAXCNT = MY_BUF_SIZE;

Three questions:

  1. What should my_rx_buf look like? Does it have to be statically allocated? Does it have to be an ArrayList with a buffer like in the "SPIM with EasyDMA" section? A code snippet for my_rx_buf would be very helpful.

  2. What should be the buffer size if I've configured my code for a sample rate of 25 ks/s (MCKFREQ=3.2 MHz and Ratio=128)?

  3. Is I2S fully functional in PCA10040 (nRF52 kit received from the nRF52 global tour)?

Thank you again for your excellent guidance & help!

Regards, Shashi Austin TX

P.S.: You're may be finishing up the samples for I2S in the nRF52 SDK. Is there a way to get the preview-version of those examples?

  • Hello.

    1 - This should be a statically allocated area of RAM. It will contain data in "chunks" of 32 bits. Whether you implement an ArrayList structure type with 4 bytes, or one array of uint32_t is up to you. If you choose the latter, you must extract the data manually from each 32 bit chunk. The allocation will look like this:

        static uint32_t m_rx_buf[I2S_BUFFER_SIZE];
    

    Remember that you can choose whether the data is going to be 8,16 or 24 bits. If you choose 16 bits, you can extract the two 16 bit words from a uint32_t varible "buffer" like this:

        uint16_t actual_sample_left   = ((uint16_t const *)buffer)[0];
        uint16_t actual_sample_right   = ((uint16_t const *)buffer)[1];
    

    2 - This really depends on how you plan to do the sampling. In BLE, you can send 20 bytes in one packet. It will make sense to gather 20 bytes at a time, and then send these bytes out. However, if you want to continue to sample audio while reading the previous sample from RAM, you must implement double buffering. You will in this case need two buffer of 20 bytes each, and switch between the two buffers when you get an interrupt saying that 20 bytes have been received.

    3 - Yes. You can see it on the list of fixed anomalies in the errata.

    For others, here is the link to the i2s section of the OPS

    The i2s driver and example project will be released in the next SDK. (Probably just before Christmas this year)

    adpcm codec: dvi_adpcm.rar

  • Hi Anders,

    Thank you! That info was very helpful. I look forward to the example project and i2s driver.

    From this thread, I can get a peak throughput of 32kbps to 128kbps depending upon the connection interval and number of packets per interval. That means with a 24-bit MEMS microphone, I would have to use a sample rate of <2khz. I will give this a try and look at the audio quality received on my other device via BLE.

    I noticed that nRFready Voice Input Module uses ADPCM codec for audio compression. Is that codec available in the SDK or somewhere? Is it possible to use ADPCM codec with nRF52 when using i2s interface and S132? I understand that CPU is not always available as some CPU cycles will be taken by S132.

    Also, If I need higher quality audio, (as a non-ideal solution) I could have some onboard external flash memory (as SPI slave) that I can write my 10-second high-quality audio clips and send them via BLE asynchronously.

    Thank you again for your excellent help!

  • The codec is open source. I am not sure if you can use it with i2s. I guess the audio signal must be in pcm format for it to work. I am not sure where you can download the codec, so i will attach it to my answer.

  • Hi Anders,

    Is there a full version of the ADPCM encoding and decoding of the document can provide reference, thank you!

Related