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

PDM - nRF52840 SDK 15.2

I'm having trouble with PDM on SDK15.2 with nRF52840.

The raw data buffers are only half full. The last half are zero's, therefore recorded voice has a robotic sound to it.

What I tried:

1) Went thru Thingy firmware thoroughly. As the other forum posts indicate, its in SDK 13 and using the nfx/legacy migration drivers are not 1:1 when handling the buffers.

2) My initial code base was with the nfx driver. It basically works but has the 1/2 data missing issue mentioned above.

3) I rewrote the driver using the same nrf_pdm calls, similar to Thingy's SDK 13 driver. And its having the same 1/2 data issue also.

4) Connected analyzer to the PDM lines and verified that the DATA is not zero during the 1/2 buffer time.

It almost like nRF's PDM is looking for a Right-side mic (stereo) but its set to MONO

nrf_pdm_mode_set((nrf_pdm_mode_t) NRF_PDM_MODE_MONO, (nrf_pdm_edge_t) NRF_PDM_EDGE_LEFTRISING)

Here is my code setup.

  • Btw, the MEMS used is either a MP34DT01-M or a SPK0415HM4H on an Adafruit dev board.

    ... and I've tried both rising and falling edge.

  • After many hours.... just found the bug. It was on my side.

    The memcpy(ptrBuffer->buf, p_buffer, samples); was only copying half the data. Should be memcpy(ptrBuffer->buf, p_buffer, (samples * sizeof(int16_t))); ..... well duh, so it goes.