<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example</link><description>Hello, 
 I am currently interfacing my nRF52840 DK with i2S based MP34DT05 sensor. I am using nrfx i2s driver&amp;#39;s for interfacing with sensor. I am using master clk of 2MHz, LCLK 16KHZ. 
 My sensor output PDM data. In my project I am recording audio samples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Jun 2021 10:46:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example" /><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/315348?ContentTypeID=1</link><pubDate>Tue, 15 Jun 2021 10:46:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a09b8a44-be8d-43c9-805c-f283cf9df0c1</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;You could try making the printouts more efficient. For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;		static char str[4000 * 4 + 1];
		size_t len = 0;

		for(int i=0; i&amp;lt;4000;i++)
		{
			int err = snprintf(&amp;amp;str[len], sizeof(str) - len, &amp;quot;%04X&amp;quot;, (unsigned short) audio_block-&amp;gt;buffer[i]);
			if (err &amp;lt; 0 || err &amp;gt; 4)
			{
				printk(&amp;quot;Format error: %d\n&amp;quot;, err);
				return;
			}
			len += err;
		}
		printk(&amp;quot;%s\n&amp;quot;, str);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/315065?ContentTypeID=1</link><pubDate>Mon, 14 Jun 2021 09:42:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bad6d237-4e86-4594-acbe-a910fa5e9e76</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I see a couple of problems here, some from my code reference in earlier reply:&lt;/p&gt;
&lt;p&gt;1) You don&amp;#39;t need both &amp;quot;K_MEM_SLAB_DEFINE&amp;quot; and &amp;quot;struct k_mem_slab audio_slab;&amp;quot;. Same for FIFO&lt;/p&gt;
&lt;p&gt;2) The mem slab needs to be at least 3 blocks long. The PDM driver will request 2 blocks right away, and request a third before you will have had time to process the first released one:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//Memory slab
K_MEM_SLAB_DEFINE(audio_slab, sizeof(struct data_item_t), 3, 4);

//FIFO to hold pointers to memory slab
K_FIFO_DEFINE(my_fifo);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3) No double-pointer to k_fifo_put. It should be like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;k_fifo_put(&amp;amp;my_fifo, filled_block);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;4) k_sleep() must be removed from Microphone_Start_Record(). Otherwise slab will be emptied while the main thread is sleeping. If you want to skip the first X seconds of audio, you need to free the first Y blocks in main() without printing them out first (k_mem_slab_free)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/314461?ContentTypeID=1</link><pubDate>Wed, 09 Jun 2021 12:35:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6474ef8-c716-49c7-87c1-610361256ac9</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I suggest changing the data_item_t struct slightly to make it easier to get the block size right. Currently you have to manually make sure that the slab definition has block size that matches sizeof struct + *buffer:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;struct data_item_t {
    void *fifo_reserved;   /* 1st word reserved for use by FIFO */
    int16_t buffer[16000]; /* 1 second of mono audio @ 16 kHz */
};

//Memory slab
struct k_mem_slab audio_slab;
K_MEM_SLAB_DEFINE(audio_slab, sizeof(struct data_item_t), 2, 4);

//FIFO to hold pointers to memory slab
struct k_fifo my_fifo;
K_FIFO_DEFINE(my_fifo);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now you can request a buffer in the pdm handler, and put filled buffers into the fifo:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrfx_pdm_event_handler(nrfx_pdm_evt_t const * p_evt)
{
	if(p_evt-&amp;gt;buffer_requested)
	{
		struct data_item_t *new_block;
		int err;

		err = k_mem_slab_alloc(&amp;amp;audio_slab, (void**) &amp;amp;new_block, K_NO_WAIT);
		if (err) {
			printk(&amp;quot;alloc fail\n&amp;quot;);
		} else {
			nrfx_err_t nrfx_err = nrfx_pdm_buffer_set(new_block-&amp;gt;buffer, ARRAY_SIZE(new_block-&amp;gt;buffer));
			if (nrfx_err != NRFX_SUCCESS) {
				printk(&amp;quot;nrfx_pdm_buffer_set: %d\n&amp;quot;, nrfx_err);
				// Free block if set buffer fails
				k_mem_slab_free(&amp;amp;audio_slab, (void**) &amp;amp;new_block);
			}
		}
		
	}
	if(p_evt-&amp;gt;buffer_released != 0)
	{
		struct data_item_t *filled_block;

		// Get pointer to data_item_t which the released buffer is part of
		filled_block = CONTAINER_OF(p_evt-&amp;gt;buffer_released, struct data_item_t, buffer);
		k_fifo_put(&amp;amp;my_fifo,&amp;amp;filled_block);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Your main loop (or somewhere else that is not in the ISR) can then fetch data from the fifo and process it:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;struct data_item_t *audio_block;

audio_block = k_fifo_get(&amp;amp;my_fifo, K_FOREVER);
if (audio_block == NULL) {
	printk(&amp;quot;fifo error\n&amp;quot;);
} else {
	// TODO: Process audio_block-&amp;gt;buffer

	k_mem_slab_free(&amp;amp;audio_slab, (void**) &amp;amp;audio_block);
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/314331#314331"]In the python script you gave me why do we require extra processing after creating a PCM list of integers in first couple of lines.&amp;nbsp; Is it just to generate .wav files or it have anything to do with PCM data directly. Also in PCM list we have converted negative int to positive int.[/quote]
&lt;p&gt;The extra processing is indeed to make python wave library happy. The human-readable format would be signed 16-bit integers. That is, numbers in the range [-32767, 32767]. Your text output was as unsigned hex, which needed some massaging for python wave.&lt;/p&gt;
[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/314331#314331"]So is it required to transform the data received from PDM interface in little endian format to train the model ? From the Nordic docs &amp;quot;If OPERATION=Mono, RAM will contain a succession of mono samples.&amp;quot; i am assuming i can directly use the raw PCM data available in my int16_t buffer for training and testing. [/quote]
&lt;p&gt;You should be able to use the raw PCM data (int16_t) directly. The questions is what format you use to transfer it from the nRF52840 to your training system. You can print it as text (like you did before), or in some binary format. Text is easier to read, but has more overhead than a binary format. The easiest is probably to match the expected input format in your training system, assuming the UART is fast enough to transfer this format.&lt;/p&gt;
&lt;p&gt;If you transfer the data over UART as a binary format, you need to take the endianness into account in the training system. For example, lets say on the host side you read the audio as a 32000 byte buffer. To convert 32000 bytes into 16000 signed 16-bit integers, the proper endianness must be known.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313858?ContentTypeID=1</link><pubDate>Mon, 07 Jun 2021 09:29:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a89f5c7c-1c38-4ad1-88ad-ff2cf65aa9c0</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Btw, I realized I linked to and old version of the documentation, but these function names have not changed as far as I know. Also, note that in the PDM ISR/handler, you must used timeout value K_NO_WAIT&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313838?ContentTypeID=1</link><pubDate>Mon, 07 Jun 2021 08:47:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2c0639e-1993-4f88-9c5d-4d6fca6b5099</guid><dc:creator>Audun</dc:creator><description>[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/313642#313642"]If you find any bug in above code kindly mention or have any another tricks than please help because i can&amp;#39;t recognize voice patterns just on the basis of 2-3 sec audio.[/quote]
&lt;p&gt;I think it would make things easier if you use some data structures to help organize the PCM buffers. Specifically, I recommend using a &lt;a href="https://docs.zephyrproject.org/1.9.0/kernel/memory/slabs.html"&gt;memory slab&lt;/a&gt; for allocating PCM buffers, and a &lt;a href="https://docs.zephyrproject.org/1.9.0/kernel/data_passing/fifos.html"&gt;queue/FIFO&lt;/a&gt; to enqueue PCM buffers that have been filled.&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say your algorithm runs on audio block sizes of 100 milliseconds, at 16 kHz sampling rate, this means each audio block is 3200 bytes. You would then define a memory slab of size X * 3200. X can be any number that fits within total memory. Note that it is probably best to define a struct for your audio data, which contains the int16_t audio buffer, plus the fifo_reserved data field, plus whatever else might be useful.&lt;/p&gt;
&lt;p&gt;In the PDM event hander, when a new buffer is requested, you try to allocate a new buffer from the slab (&lt;span class="n"&gt;k_mem_slab_alloc&lt;/span&gt;&lt;span class="p"&gt;&lt;/span&gt;). If this fails, you can log the error.&lt;/p&gt;
&lt;p&gt;In the PDM event handler, when a freshly filled buffer is released, you put the pointer to this buffer in the FIFO (&lt;span class="n"&gt;k_fifo_put&lt;/span&gt;&lt;span class="p"&gt;&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;Your algorithm can run as soon as there is one or more items in the FIFO (&lt;span class="n"&gt;k_fifo_get&lt;/span&gt;&lt;span class="p"&gt;&lt;/span&gt;). &lt;/p&gt;
&lt;p&gt;Once the algorithm has finished processing one audio buffer, it will release it back to the memory slab (&lt;span class="n"&gt;k_mem_slab_free&lt;/span&gt;&lt;span class="p"&gt;&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;This way your algorithm will always process the audio in order, and it is easy to see if you have a bottleneck somewhere.&lt;/p&gt;
&lt;p&gt;If you have multiple consumers of your audio data (e.g. local algorithm plus UART printout), this can be solved by adding a reference counter to the audio buffer struct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313608?ContentTypeID=1</link><pubDate>Fri, 04 Jun 2021 10:29:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62a14f90-fecb-4f43-ae5f-fbaad907e41f</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;The UART baud rate might be an issue here. The default is 115200 baud, while your audio is 16-bit * 16 kHz = 256000. To test if this is the problem, you can try setting the board baud rate to 1000000 instead of 115200. The proper way to do this is to set up an overlay file in your sample, but as a quick test you can also update this config: &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts#L146"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts#L146&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also recommend checking out the USBD audio sample: &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/master/samples/subsys/usb/audio/headset"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/master/samples/subsys/usb/audio/headset&lt;/a&gt; This sample makes the nRF52840-DK appear as an audio device when connected to a USB host. With this you could copy the audio from the PDM directly to USB, and listen to the audio in real time on your computer without any additional scripts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313429?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 13:03:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0d6b597-e3a9-42e1-bdbe-e4b940ec08ba</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;This seems to work better. Tested using python3.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;import sys
import wave
import re
import struct

with open(&amp;#39;0317.test.txt&amp;#39;, &amp;#39;r&amp;#39;) as pcmfile:
    # Convert comma-separated hex strings into list of integers
    pcm_list = list(map(lambda x: int(x, 16), re.findall(r&amp;#39;([\w\d]+)&amp;#39;, pcmfile.read())))

# Convert list of integers into little endian-encoded byte array
pcmdata = bytes()
    
for sample in pcm_list:
    # Original sample is signed 16-bit. Format as uint16, and decode as int16.
    tmpdata = struct.pack(&amp;#39;&amp;lt;H&amp;#39;, sample)
    tmpdata = struct.unpack(&amp;#39;&amp;lt;h&amp;#39;, tmpdata)[0]
    pcmdata += struct.pack(&amp;#39;&amp;lt;h&amp;#39;, tmpdata)
    
with wave.open(&amp;#39;0317.test.wav&amp;#39;, &amp;#39;wb&amp;#39;) as wavfile:
    wavfile.setparams((1, 2, 16000, 0, &amp;#39;NONE&amp;#39;, &amp;#39;NONE&amp;#39;))
    wavfile.writeframes(pcmdata)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313421?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 12:50:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13251a5e-5e07-49af-9e05-802e85e78e9c</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;there are a couple of problems with the script and data:&lt;br /&gt;1) wavfile.writeframes() needs raw int16_t byte data, not a string. Your read the text file as a string, but to put it in writeframes each of the values in the comma-separated string needs to be extracted and formatted into a continuous array of formatted bytes.&lt;/p&gt;
&lt;p&gt;2) The first parameter (number of channels) in wavfile.setparams is 2, but the data seems to be single channel? How is the PDM peripheral configured in the code?&lt;/p&gt;
&lt;p&gt;3) I would recommend printing your buffer as int16_t (signed short), as this is the PCM format generated by the PDM peripheral. When I plot the data it looks somewhat good, but there also seems to be some formatting error going on in the printouts:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1622724635366v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/313061?ContentTypeID=1</link><pubDate>Wed, 02 Jun 2021 10:42:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5e2794d-b831-4589-a348-5f24e9726590</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Sorry, I have been thinking about this one for a bit, and I don&amp;#39;t have any good ideas. I checked if it could be a VDD supply issue regarding nRF_USB, but I don&amp;#39;t think that is a problem. VDD on the headers should be able to supply external circuitry regardless of which USB connection you have used.&lt;/p&gt;
&lt;p&gt;I think it would be worthwhile to test another sensor, in case this particular unit is faulty.&lt;/p&gt;
&lt;p&gt;To summarize: You&amp;#39;ve verified that VDD and CLK is within the sensor specification (albeit in the lower end for the clock, but that should not matter), but still the output does not look good. You&amp;#39;ve also verified that there is no external circuitry messing with the output signal, by disconnecting the data line. I think the next step would be to try another sensor unit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/312043?ContentTypeID=1</link><pubDate>Thu, 27 May 2021 11:17:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:370eb74b-f540-4d85-b543-5f8a1c7496aa</guid><dc:creator>Audun</dc:creator><description>[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/311948#311948"]Can it be a problem with my sensor ? It is outputting at PDM CLK rate but false data. &amp;nbsp;[/quote]
&lt;p&gt;It&amp;#39;s possible. If you have another sensor at hand, it would be worth checking.&lt;/p&gt;
&lt;p&gt;I re-read your description the setup. Am I understanding correctly that you don&amp;#39;t have this USB connected?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1622114220159v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you measured the voltage on the sensor VDD?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/311854?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 14:22:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4396e972-d47b-4a05-90e5-7d6d424c32e5</guid><dc:creator>Audun</dc:creator><description>[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/311764#311764"]&lt;p&gt;&lt;strong&gt;L/R pin connection Information&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When i see the nRF52840 PDM docs (Fig 2), it shows i have to connect L/R pin to VDD for left channel, but my sensor say opposite.&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;I wouldn&amp;#39;t worry so much about the L/R selection or clock edge details at this stage. In my experience when only one microphone is connected to the PDM peripheral,&amp;nbsp;the data signal will in effect end up in both channels as no other sensor is driving the data line for the other channel. Regardless, you can configure the nrfx pdm driver to sample stereo and sort out the exact channel details later.&lt;/p&gt;
&lt;p&gt;Your hardware setup sounds sensible. The MP34DT05 supply voltage falls within VDD on the nRF52840-DK. I think VDD on nRF52840-DK defaults to 1.8V, but I&amp;#39;m not 100% sure.&lt;/p&gt;
[quote userid="104261" url="~/f/nordic-q-a/75483/nrfx-based-pdm-to-pcm-implementation-i2s-example/311764#311764"]Okay will also check that and will also use python script on the same. Any others suggestions or guidance is also appreciated.[/quote]
&lt;p&gt;In terms of electrical setup, wire length could be an issue.&lt;/p&gt;
&lt;p&gt;In the logic analyzer trace made at the sensor, I also noticed that the two signals seems very similar. It&amp;#39;s hard to tell from just this snippet, but could there be a short between the clock and data lines?&lt;/p&gt;
&lt;p&gt;This screenshot below was taken a while ago, but shows the kind of pattern I would expect to see on the PDM clock and data lines:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1622039005096v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/311749?ContentTypeID=1</link><pubDate>Wed, 26 May 2021 11:24:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e641c278-a95d-45af-8d3b-4ba7e5401b7b</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Thanks for the Logic analyzer traces!&lt;/p&gt;
&lt;p&gt;The logic analyzer trace from the sensor directly looks to be more in range of the expected frequency, but it&amp;#39;s hard to say if it&amp;#39;s good or not just by looking at this snippet. Did you try running the python script on this measurement?&lt;/p&gt;
&lt;p&gt;It&amp;#39;s possible that the issue is electrical. What does your test setup look like? Are you powering the sensor from one of the nRF52840-DK headers, or is there a separate supply? Are there other components connected to the CLK or DIN lines?&lt;/p&gt;
&lt;p&gt;I would recommend connecting the CLK signal to the sensor, but keep the DIN line to nRF52840 disconnected. This way you can measure the data output on the sensor again, without getting potential interference from the nRF52840-DK. For example if the nRF52840 is configured with a pull resistor on P1.05, this could influence the signal level.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/311475?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 13:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42bdf0fa-0763-4e6a-9c8a-4e04c0f5d330</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;first off, I would recommend printing out the entire pdm_buf array and look at the contents. The microphone has a ~10 ms startup time (see below), so it is likely that the first sample in the first buffer will always be the same value.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1621946952892v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Second, data on the DIN pin is normally in the same frequency range as the clock signal, but this will vary according to the acoustic input to the sensor.&lt;/p&gt;
&lt;p&gt;If you want to validate the DIN signal you see in the logic analyzer, you can try the attached python script. The script parses and filters an exported .csv from Saleae Logic analyzer software. Just make sure the exported csv has DIN as the first exported value. For example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Time [s],Channel 5,Channel 7
-0.000051150,0,0
0.000000000,1,0
0.000000030,1,1
0.000999980,0,1
0.001000018,0,0
0.001999976,1,0
0.002000010,1,1
0.002999954,0,1
0.002999998,0,0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here, channel 5 is DIN, and Channel 7 is CLK.&lt;/p&gt;
&lt;p&gt;Python script syntax, using 16 kHz as target PCM rate:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ python pdm_parse.py my_exported_saleae_capture.csv 16000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/pdm_5F00_parse.py"&gt;devzone.nordicsemi.com/.../pdm_5F00_parse.py&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFX based PDM to PCM implementation (I2S example)</title><link>https://devzone.nordicsemi.com/thread/311448?ContentTypeID=1</link><pubDate>Tue, 25 May 2021 12:20:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2acb6269-1f63-4e56-81d7-1d4eae0968d6</guid><dc:creator>Audun</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;instead of the NRFX I2S driver, it sounds like you should use the NRFX PDM driver: &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__pdm.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__pdm.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The PDM driver interfaces with the PDM hardware on nRF52840: &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pdm.html?cp=4_0_0_5_14"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/pdm.html?cp=4_0_0_5_14&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The PDM hardware has the decimation filtering built into hardware, and outputs PCM samples. Two decimation factors are supported, 64 and 80. For example, if you want a 16 kHz PCM rate, you should choose a PDM clock rate of 1.28 MHz, and a decimation factor of 80.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Audun&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>