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

I2S does not work as expected on nRF52832

Hello,

some time ago I was struggling with interfacing an I2S microphone with the nRF52832. That remained unsuccessful. My conclusion back then was that the selected I2S microphone and the nRF52832 were incompatible (the mic wanted 32-bit word size, which the nRF did not support).

In a current project, I -again- need to interface an I2S device to A/D convert the analog data from a MEMS microphone. This time a WM8731 codec, which is known to be very versatile and universally interfaceable. Since the WM8731 specification states that it supports different word lengths (16, 20, 24, or 32 bit), I was very positive that it can be used with the Nordic chip.

It seems I was wrong.

I took a small test board consisting of the WM8731 and the most necessary external components as recommended by the manufacturer and connected it with a Knowles analog MEMS microphone. This setup works flawlessly with a SAM4L development board.

With the Nordic nRF52 development board (PCA10040, v1.1.0) and the latest SDK (v13.0) the TWI communication (for setting up the codec) works and the codec also starts providing the samples over I2S, but I only see scrambled data in the Nordic's I2S buffers. I double and triple checked all my methods as well as the clock and codec configuration - they should work, but they don't.

I also played with different bitstream formats, which both sides (the codec and the nRF52) "speak". I made some recordings with a 1 kHz sine as input. Here are the results:

REC_I2S.wav

REC_LEFT-ALIGNED.wav

REC_RIGHT-ALIGNED.wav

As for the recording, I write the data from an intermediate buffer to an SD-Card (based on the SD-Card example). This uses SPI (and EasyDMA). Some parts of the recordings sound like as if the SPI and the I2S transfers would disturb each other. I hope that is not true.

I also tried different MCL speeds (4, 8, 10.6, 16 MHz), different left-right-clock ratios (CONFIG.RATIO), bit-depths (CONFIG.SWIDTH), but nothing works right. If the recording sounds fine for 50 ms, then it gets totally distorted right after that (as if the sync between nRF52 and the codec would be gone).

Here is a simple question to the crowd out there: did anyone manage to interface any audio codec that works perfectly with the nRF52832?

If yes, please tell me which codec it was and what settings worked.

If not, I am tempted to believe that the I2S interface of the nRF52832 is buggy and hence useless.

Parents
  • Hi, I managed to set nRF52832 working on custom PCB with MAX98357A Class-D amplifier connected over I2S and it works very well. Might not be 100% relevant as you have opposite use case (I2S as input to nRF52) but I would double check:

    • What exact coding on 3-wire interface is configured in your A2D (they typically support I2S, Left-justified and TDM, all with Mono or Stereo, different bit resolutions and different sampling frequencies = in total easily 10-20 configurations leading to "noise" decoding if not aligned on both sides).
    • Observe 3-wire interface with logical analyzer and try to decode it manually to confirm it's exactly what it should be.
    • Double check if you are not affected by one of three I2S anomalies existing on nRF52832 Rev 1.

    Sample recordings with monotone signal (or is it just background noise?) you provide are not helping much but if I understand it correctly it works, there are just some crackling noise cuts. Are you sure that you have correctly implemented both I2S input and SPI output with at least two DMA buffers which make sure that while one is being read the other is being sent over SPI? I managed to get pretty nice opposite application (reading over SPI from external flash and playing over I2S) but it was little flaky when there was heavy BLE activity (because even with 100-250B buffers in "swing" implementation you need to have some computing time to shift the indexes so if you are blocked for longer period then is one of your I2S input/SPI output blocks you can see crackling effects similar to what you present here).

  • Hi,

    thank you very much for the quick reply! I am happy to hear that I2S of the nRF52 worked for you! :) The two main differences I see are a) the direction of the stream (Nordic->Codec in your case) and b) no need of an MCL with the MAX98357A.

    Regarding your points to double check:

    • I use a 2-wire interface (TWI) to set up the codec. I already checked it and the TWI part works perfectly.
    • I am not affected by the currently listed I2S anomalies.
    • I already tried various formats, bit depths, mono and stereo, and sampling frequencies, which both sides (Nordic and Codec) support, but no success.
    • My buffers are large enough and handling is OK.

    Next week I will have access to a 4-channel oscilloscope and I will have a closer look on the I2S stream. Until then I may try to use the codec to play back something from the nRF52 and see if that direction works.

    Thanks again, Tamas

Reply
  • Hi,

    thank you very much for the quick reply! I am happy to hear that I2S of the nRF52 worked for you! :) The two main differences I see are a) the direction of the stream (Nordic->Codec in your case) and b) no need of an MCL with the MAX98357A.

    Regarding your points to double check:

    • I use a 2-wire interface (TWI) to set up the codec. I already checked it and the TWI part works perfectly.
    • I am not affected by the currently listed I2S anomalies.
    • I already tried various formats, bit depths, mono and stereo, and sampling frequencies, which both sides (Nordic and Codec) support, but no success.
    • My buffers are large enough and handling is OK.

    Next week I will have access to a 4-channel oscilloscope and I will have a closer look on the I2S stream. Until then I may try to use the codec to play back something from the nRF52 and see if that direction works.

    Thanks again, Tamas

Children
No Data
Related