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
  • Hello newtom

    I apologize for the late reply

    The fact that the 1kHz noise is not affected by any of the changes you make leads me to believe it is caused by either the power supply, or possibly something on a timer running with a 1ms interval. How have you powered your system? If you are powering it through USB, I would like you to try and switch to a battery, or at least a more clean running power supply, and see if that clears up the noise. If it doesn't, see if you have any timers running, or if anything with a high current consumption triggers (i.e. the radio), with a 1ms interval.

    It would also be interesting to know if the distortions are present on the data sent from the Codec, or if it is generated on being received at the nRF. If you could use a logic analyzer and look at the data outputted from the codec that could be helpful. As for the SD-card noise, are the pins you use for the SPI and I2S close to each other?

    Best regards

    Jørn Frøysa

Reply
  • Hello newtom

    I apologize for the late reply

    The fact that the 1kHz noise is not affected by any of the changes you make leads me to believe it is caused by either the power supply, or possibly something on a timer running with a 1ms interval. How have you powered your system? If you are powering it through USB, I would like you to try and switch to a battery, or at least a more clean running power supply, and see if that clears up the noise. If it doesn't, see if you have any timers running, or if anything with a high current consumption triggers (i.e. the radio), with a 1ms interval.

    It would also be interesting to know if the distortions are present on the data sent from the Codec, or if it is generated on being received at the nRF. If you could use a logic analyzer and look at the data outputted from the codec that could be helpful. As for the SD-card noise, are the pins you use for the SPI and I2S close to each other?

    Best regards

    Jørn Frøysa

Children
Related