<?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>PDM microphone interface</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71403/pdm-microphone-interface</link><description>HI sir i was trying to interface pdm microphone. i followed the existing ticket PDM Driver for Zephyr on nrf52840 . i had modified the proj.conf as below 
 
 but during the loading process i got the error as below 
 I am not able to find what is causing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Mar 2021 15:34:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71403/pdm-microphone-interface" /><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/297264?ContentTypeID=1</link><pubDate>Tue, 02 Mar 2021 15:34:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de9029bb-ae8b-426f-97da-d5a6df87ff15</guid><dc:creator>Y0g1</dc:creator><description>&lt;p&gt;sorry for being late i will check and revert u thanks for quick response.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/295958?ContentTypeID=1</link><pubDate>Wed, 24 Feb 2021 08:39:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4092b040-6727-483e-81a0-09b9ab6685e7</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As mentioned, you only need to set the config NRFX_PDM=y and set the peripheral as non-secure in spm.c, no need to add the CONFIG_COMPILER_OPT=&amp;quot;...&amp;quot; with ncs v1.4.0 and newer.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Y0g1"]i followed the link and set the values as described to spm.c now the pdm functions are working but still in dts file pdm shows disabled as below[/quote]
&lt;p&gt;DT does not have any impact when using the nrfx driver directly. You are accessing the hardware peripheral directly without using the zephyr driver API.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Y0g1"]which gives false as output. inspite all this the output i got is like this[/quote]
&lt;p&gt;&amp;nbsp;This function will only return true if the PDM is started, not initialized. Try checking this after you call&amp;nbsp;nrfx_pdm_start().&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Y0g1"]which gives false as output. inspite all this the output i got is like this[/quote]
&lt;p&gt;&amp;nbsp;Can you try to let the PDM run for 1 second before stopping it? Like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;	nrfx_pdm_start();
	bool enabled = nrfx_pdm_enable_check();
	printk(enabled ? &amp;quot;true/n&amp;quot; : &amp;quot;false\n&amp;quot;);	
	k_msleep(1000);

	nrfx_pdm_stop();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/295902?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 16:04:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03ebf91b-be49-4b38-a02b-377adbc2e522</guid><dc:creator>Y0g1</dc:creator><description>&lt;p&gt;thanks for quick reply. i followed the link and set the values as described to spm.c now the pdm functions are working but still in dts file pdm shows disabled as below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;pdm0: pdm@26000 {
				compatible = &amp;quot;nordic,nrf-pdm&amp;quot;;
				reg = &amp;lt; 0x26000 0x1000 &amp;gt;;
				interrupts = &amp;lt; 0x26 0x1 &amp;gt;;
				status = &amp;quot;disabled&amp;quot;;
				label = &amp;quot;PDM_0&amp;quot;;
			};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i also included&amp;nbsp;nrfx.h which includes nrfx_config.h which clearly showing the value&amp;nbsp;NRFX_PDM_ENABLED 1.&lt;/p&gt;
&lt;p&gt;i am using function&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;bool enabled = nrfx_pdm_enable_check();
	printk(enabled ? &amp;quot;true/n&amp;quot; : &amp;quot;false\n&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;which gives false as output. inspite all this the output i got is like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.4.0-ncs1  ***
Starting PDM program!
PDM Buffer size: 3072 in 16 bit words
false
pins init!
195887104
false
200101d8 is the starting address
   0 is current value at 200101d8
The PDM will start reading NOW...
Out:    0 @ 0x200101d8
    0 @ 0x200101da
Out:    0 @ 0x200101d8
    0 @ 0x200101da
   0 is current value at 200101d8
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i was trying to find out the reason that which file is over writing the pdm enable configuration. i am again including the proj.conf settings below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PRINTK=y
CONFIG_I2C=y
CONFIG_GPIO=y
CONFIG_NRFX_PDM=y

CONFIG_DEBUG=y 
#CONFIG_REBOOT=n

CONFIG_COMPILER_OPT=&amp;quot;-DNRF_PDM=NRF_PDM_NS -DNRFX_PDM_ENABLED=1&amp;quot;


&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;kindly check into this and help me to resolve the issue as explained before i am using a custom pcb with conf&amp;nbsp;nrfx_pdm_config_t pdm_config = NRFX_PDM_DEFAULT_CONFIG(1, 0); . please guide me to resolve the issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/295741?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 08:31:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62d7c7e7-6dcf-40e9-9382-b46ed1b5eb10</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;My apologies, the peripheral needs to be marked as non-secure in spm.c, as shown here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/68472/pdm-mic-on-nrf9160dk-and-spm/281880#281880"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/68472/pdm-mic-on-nrf9160dk-and-spm/281880#281880&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you try this and see if it works better now?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/295464?ContentTypeID=1</link><pubDate>Sun, 21 Feb 2021 17:02:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bba27b80-0821-4040-99fd-76ddf7fd3aa0</guid><dc:creator>Y0g1</dc:creator><description>&lt;p&gt;sir&amp;nbsp;&lt;/p&gt;
&lt;p&gt;i tried as per your guide here are my observations&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;1. First thing is to add the sources in zephyr/ext/hal/nordic/CMakeLists.txt:

zephyr_sources_ifdef(CONFIG_NRFX_PDM nrfx/drivers/src/nrfx_pdm.c)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i checked out my ncs v 1.4.0 the file i found at location&amp;nbsp;ncs/modules/hal/nordic/&lt;span&gt;CMakeLists.txt which contains the setting as discussed above&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;2. And you also need to add these two lines to zephyr/ext/hal/nordic/Kconfig:
config NRFX_PDM
    bool&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i didnt find the second file location so can&amp;#39;t able to verfy that.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;3. Now we start on the application side. you need to append this to your prj.conf:
    CONFIG_COMPILER_OPT=&amp;quot;-DNRF_PDM=NRF_PDM_NS -DNRFX_PDM_ENABLED=1&amp;quot;
    
4. Next up is selecting the NRFX_PDM in Kconfig. This is a symbol that needs to be selected by a module, so let&amp;#39;s add one to your application.
        mainmenu &amp;quot;PDM test&amp;quot;

        config FORCE_PDM
        	bool &amp;quot;Test to force PDM&amp;quot;
        	select NRFX_PDM
            default y
        
        source &amp;quot;$ZEPHYR_BASE/Kconfig.zephyr&amp;quot;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;both steps are done correctly&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i also included the code below in main.c as per your saying&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;ISR_DIRECT_DECLARE(pdm_isr_handler)
{
	nrfx_pdm_irq_handler();
	ISR_DIRECT_PM(); /* PM done after servicing interrupt for best latency
			  */

	return 1; /* We should check if scheduling decision should be made */
}

void main(void)
{
	IRQ_DIRECT_CONNECT(PDM_IRQn, 0,
			   pdm_isr_handler, 0);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;but no luck the code output i got on terminal is like below it got stuck with any function called related to nrfx pdm.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.4.0-ncs1  ***
Starting PDM program!
PDM Buffer size: 3072 in 16 bit words
pins init!
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;here is the code i used for tesitng found in some other tickets if that help you to guide me for the error&amp;nbsp;&lt;/span&gt;resolution&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*  
		C Program to run a pulse density modulation (PDM) Microphone on the nRF9160 Dev Kit using the Nordic SDK
*/

#include &amp;lt;nrf9160.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;nrfx_pdm.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;



#define PDM_BUF_SIZE 3072  //length of buffer in 16 bit words

int16_t pdm_buf[PDM_BUF_SIZE];

void nrfx_pdm_event_handler(nrfx_pdm_evt_t const *const p_evt)
{
	if (p_evt-&amp;gt;buffer_requested) {
		nrfx_pdm_buffer_set(pdm_buf, PDM_BUF_SIZE);
	}
	if (p_evt-&amp;gt;buffer_released != 0) {
		printk(&amp;quot;Out: %4x @ 0x%x\r\n %4x @ 0x%x\r\n&amp;quot;,
		       (uint16_t)pdm_buf[0], &amp;amp;pdm_buf[0],
		       (uint16_t)pdm_buf[1], &amp;amp;pdm_buf[1]);
	}
}

static void pdm_init(void)
{
	nrfx_pdm_config_t pdm_config = NRFX_PDM_DEFAULT_CONFIG(
		1, 0); /*configures CLK to pin 01 and Din to pin 00*/
                printk(&amp;quot;pins init!\n&amp;quot;);
	int err = nrfx_pdm_init(&amp;amp;pdm_config, nrfx_pdm_event_handler);
        printk(&amp;quot;%u\n&amp;quot;,err);
}

/*ISR workaround given by Nordic*/
ISR_DIRECT_DECLARE(pdm_isr_handler)
{
	nrfx_pdm_irq_handler();
	ISR_DIRECT_PM(); /* PM done after servicing interrupt for best latency
			  */

	return 1; /* We should check if scheduling decision should be made */
}

void main(void)
{
	IRQ_DIRECT_CONNECT(PDM_IRQn, 0, pdm_isr_handler, 0);  //workaround line 
	printk(&amp;quot;Starting PDM program!\n&amp;quot;);
	printk(&amp;quot;PDM Buffer size: %d in 16 bit words\n&amp;quot;, PDM_BUF_SIZE);

	/*
	bool enabled = nrfx_pdm_enable_check();
	printk(enabled ? &amp;quot;true/n&amp;quot; : &amp;quot;false\n&amp;quot;);
	*/

	pdm_init();
	printk(&amp;quot;%4x is the starting address\n&amp;quot;, &amp;amp;pdm_buf);
	printk(&amp;quot;%4x is current value at %x\n&amp;quot;, pdm_buf[0], &amp;amp;pdm_buf);
	printk(&amp;quot;The PDM will start reading NOW...\n&amp;quot;);
      /*  for (int i = 0; i &amp;lt; 500; i++) {
          int k = 5;
          for (volatile int j = 0; j &amp;lt; 50; j++) {
                k = !k;
		}
	}*/
	nrfx_pdm_start();
	for (int i = 0; i &amp;lt; 100; i++) {
          int k = 5;
          for (volatile int j = 0; j &amp;lt; 100; j++) {
                k = !k;
		}
	}
	nrfx_pdm_stop();

	printk(&amp;quot;%4x is current value at %x\n&amp;quot;, pdm_buf[0], &amp;amp;pdm_buf);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i am also including my proj.conf&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PRINTK=y
CONFIG_I2C=y
CONFIG_GPIO=y
CONFIG_NRFX_PDM=y

CONFIG_DEBUG=y 
#CONFIG_REBOOT=n

CONFIG_COMPILER_OPT=&amp;quot;-DNRF_PDM=NRF_PDM_NS -DNRFX_PDM_ENABLED=1&amp;quot;

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;please go through all the details and help me to resolve the error.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM microphone interface</title><link>https://devzone.nordicsemi.com/thread/293305?ContentTypeID=1</link><pubDate>Mon, 08 Feb 2021 11:09:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc8a3961-7794-494e-a79a-e2b199582b5c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you require to use the PDM interface, or the I2S interface?&lt;/p&gt;
&lt;p&gt;The example you&amp;#39;re looking at uses I2S, not PDM. Do note that zephyr doesn&amp;#39;t have a nrf-specific port for either PDM or I2S.&lt;/p&gt;
&lt;p&gt;You can use the nrfx driver directly, but this means that you cannot rely on zephyrs sensor-implementations for the specific peripheral.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are interested in PDM, you can have a look at this thread:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/57896/pdm-interface"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/57896/pdm-interface&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>