<?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>Can&amp;#39;t get PDM code to compile</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61568/can-t-get-pdm-code-to-compile</link><description>I&amp;#39;m trying to add PDM into my project but can&amp;#39;t get it to compile. When I try to call 
 
 I get the error &amp;quot;main() undefined reference to `nrfx_pdm_init&amp;#39;&amp;quot; 
 This looks like it it is in the file nrfx_pdm.c, which is included in my project - but the code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2020 09:49:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61568/can-t-get-pdm-code-to-compile" /><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/251661?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 09:49:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78ee842e-a610-4be7-b010-a21d81c9163d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;NRF_DRV_PDM_DEFAULT_CONFIG() only takes two parameters, _pin_clk and _pin_din. Try:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_drv_pdm_config_t pdm_cfg = NRF_DRV_PDM_DEFAULT_CONFIG(CONFIG_IO_PDM_CLK, CONFIG_IO_PDM_DATA);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;please check the definition in nrfx_pdm.h. This will set pdm_cfg with the following parameters:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;pdm_cfg =                   \
{                                                                     \
    .mode               = (nrf_pdm_mode_t)NRFX_PDM_CONFIG_MODE,       \
    .edge               = (nrf_pdm_edge_t)NRFX_PDM_CONFIG_EDGE,       \
    .pin_clk            = _pin_clk,                                   \
    .pin_din            = _pin_din,                                   \
    .clock_freq         = (nrf_pdm_freq_t)NRFX_PDM_CONFIG_CLOCK_FREQ, \
    .gain_l             = NRF_PDM_GAIN_DEFAULT,                       \
    .gain_r             = NRF_PDM_GAIN_DEFAULT,                       \
    .interrupt_priority = NRFX_PDM_CONFIG_IRQ_PRIORITY                \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The rest of the parameters are probably from your sdk_config.h and/or apply_old_config.h.&lt;/p&gt;
&lt;p&gt;Search for the definitions in your project to see where they are set and changed (apply_old_config.h).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since you have a project up and running, I assume you have called something like nrf_drv_pdm_init() -&amp;gt; nrf_drv_pdm_start(), and possibly a nrf_drv_pdm_buffer_set() in between these two (and you may or may not have used the nrfx_... function names directly, instead of the legacy names, which you can find in nrf_drv_pdm.h).&lt;/p&gt;
&lt;div&gt;What do these function calls return? If they all return NRF_SUCCESS (=0), do you get any events in the pdm handler?&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;BR,&lt;/div&gt;
&lt;div&gt;Edvin&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/251630?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 08:24:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a81bdfc3-91c9-43d4-aa93-7f08cd305aea</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;I got some ways.&amp;nbsp;The legacy mapping didn&amp;#39;t work as the first steps failed using a code snippet posted on here&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrf_drv_pdm_config_t pdm_cfg = NRF_DRV_PDM_DEFAULT_CONFIG(CONFIG_IO_PDM_CLK,
                                                              CONFIG_IO_PDM_DATA,
                                                              m_pdm_buff[0],
                                                              m_pdm_buff[1],
                                                              CONFIG_PDM_BUFFER_SIZE_SAMPLES);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;.. failed with something like &amp;quot;macro&amp;nbsp;&lt;span&gt;NRF_DRV_PDM_DEFAULT_CONFIG passed 5 parameters but expected 2&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For a test I just set the same buffer in the event handler and it seems to do something sensible. That&amp;#39;s enough for the moment as it&amp;#39;s enabled me to finish my PCB design with a PDM microphone included.&lt;/p&gt;
&lt;p&gt;Is the event handler solely called on buffer full? I ask because there doesn&amp;#39;t seem to be any event type passed to it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/251538?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 14:45:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:359b4cff-d8c1-4120-a336-854d1f17ac7b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Did you manage to get this up and running? Did you try to start using nrf_drv_pdm_start, and provide the buffer in the event handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/251008?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 13:30:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ac46dee-8e78-4c22-9a5a-5464852d27ce</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;If this were just for GPIO or something I would agree, but the PDM seems quite different. For example the legacy driver is initialised by passing it two buffer addresses, and it fills the buffers alternately. The new driver doesn&amp;#39;t include buffers.&lt;/p&gt;
&lt;p&gt;The docs say &amp;quot;&lt;span&gt;&amp;nbsp;the sampling procedure is started by calling the&amp;nbsp;&lt;/span&gt;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__drv__pdm.html#ga78169b7f12e3ebb5aeff7be02f2b0765"&gt;nrf_drv_pdm_start&lt;/a&gt;&lt;span&gt;&amp;nbsp;function&amp;quot; and &amp;quot;The driver will immediately request a sample buffer from the user by generating an event (&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/structnrfx__pdm__evt__t.html#aa22a290acdd7586c5baa5d3fb4e8ad50"&gt;nrf_drv_pdm_evt_t::buffer_requested&lt;/a&gt;&amp;nbsp;is set). To start the sampling, you must pass the buffer by calling&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__drv__pdm.html#gac9012f2a8bf81f555c7a5b8cc50d180c"&gt;nrf_drv_pdm_buffer_set&lt;/a&gt;.&amp;quot; which is sort of contradictory.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m thinking that I call&amp;nbsp;&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__drv__pdm.html#ga78169b7f12e3ebb5aeff7be02f2b0765"&gt;nrf_drv_pdm_start&lt;/a&gt;&amp;nbsp;, and have&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrf__drv__pdm.html#gac9012f2a8bf81f555c7a5b8cc50d180c"&gt;nrf_drv_pdm_buffer_set&lt;/a&gt;&amp;nbsp;in the event handler? What I&amp;#39;m not really seeing at the moment is the workflow, how the functions &amp;amp; events hang together.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;FWIW, I don&amp;#39;t need continuous recording, a one-shot sample will be fine as the only function here is to determine ambient noise level.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;(BTW, you don&amp;#39;t strictly need hardware to test PDM if you don&amp;#39;t mind data being 0000 or FFFF - although I think that Thingy:52 includes a PDM mic?)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have nRF52832 and PCA10040 by the way with an external PDM mic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/250959?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 12:17:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f81adf5d-2fa7-4708-be76-9028b0d60505</guid><dc:creator>Edvin</dc:creator><description>[quote user="Nick_RA"]Actually as is typical I found the answer just after posting... [/quote]
&lt;p&gt;&amp;nbsp;Good &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;We have some examples in the SDK that showcase most of our peripherals, but unfortunately, it doesn&amp;#39;t look like we have one for PDM. What chip are you using?&lt;/p&gt;
&lt;p&gt;I guess the only thing I have to give you is the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__pdm.html" rel="noopener noreferrer" target="_blank"&gt;documentation for the drivers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have any HW to test PDM for, so it is a bit difficult for me to test the drivers, and you probably already know more about PDM than me. The new drivers should&amp;nbsp;work pretty much the same as the old one, from an API point of view. The main difference between the &amp;quot;legacy&amp;quot; and the nrfx drivers is that the nrfx drivers are separated from the SDK, so that they are easier to use as stand alone drivers.&lt;/p&gt;
&lt;p&gt;There is even a file that maps the old &amp;quot;legacy&amp;quot; function calls to the nrfx ones. Please check out nrf_drv_pdm.h in SDK\integration\nrfx\legacy&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't get PDM code to compile</title><link>https://devzone.nordicsemi.com/thread/250939?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 11:45:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:979d9c66-9a03-409d-88ef-326eb7d20479</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Actually as is typical I found the answer just after posting... I didn&amp;#39;t have the PDM hardware option enabled in sdk_config.h only the driver.&lt;/p&gt;
&lt;p&gt;Are there any code snippets available for using the nrfx drivers? I found a couple of posts relating to the legacy drivers but none for the newer drivers, and they seem to be quite different e.g. initialization and allocation of buffers (which is about as far as I have got at the moment)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>