<?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 Data Output</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84800/pdm-microphone-data-output</link><description>Hello, 
 I am using the Nordic PDM library to collect data from a digital microphone. I am currently storing the data in a 1k int16_t buffer and attempting to store the data in the flash to offload it. What would be the best way to output the PCM data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Jul 2023 17:56:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84800/pdm-microphone-data-output" /><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/434787?ContentTypeID=1</link><pubDate>Wed, 05 Jul 2023 17:56:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:069c9d5e-56a7-488a-8086-c3287b544f28</guid><dc:creator>tonyh</dc:creator><description>&lt;p&gt;Hello, do you remember how you got the data acquisition working? I am still seeing noise only. Thank you for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/424010?ContentTypeID=1</link><pubDate>Fri, 05 May 2023 13:17:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea371364-6704-48a8-87ff-43c42a34e7a8</guid><dc:creator>Aayushi Kanojiya</dc:creator><description>&lt;p&gt;Can you share the make and .ld file data?&amp;nbsp;&lt;br /&gt;Thanks&amp;nbsp;&lt;br /&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/358475?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2022 15:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54917fa2-6ac5-4b11-92e9-c5508006ba74</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;1) You can pass another buffer to the peripheral using the function&amp;nbsp;nrfx_pdm_buffer_set().&lt;/p&gt;
&lt;p&gt;2) Not sure I understand the question. How is the I2C clock related to the data from the PDM microphone? Does the buffer only contain sequential, decreasing values? Can you give a specific example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/355497?ContentTypeID=1</link><pubDate>Tue, 01 Mar 2022 10:38:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dcc45e27-3c5e-4d28-a93b-f315c2d31c7b</guid><dc:creator>ISN_B</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thank you for all of your help. I have gotten the data acquisition working but I&amp;rsquo;m running into a couple more roadblocks:&lt;/p&gt;
&lt;p&gt;1) Currently I am using a buffer with the greatest buffer size 35765 and accessing saving the data bytes directly through the memory output. This buffer gets rewritten every time the buffer is requested. Is there a way to iterate the memory address pointer ?&lt;/p&gt;
&lt;p&gt;2) For our project&amp;rsquo;s usage, we are looking to use a 4kHz sampling frequency for the PDM. The microphone &amp;nbsp;successfully output data 15625 sampling rate, though when I reduce the I2C clock to capture a 4kHz signal, the values are not correctly updating working the buffer and each value decrements from the last. Why might this happening?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/354765?ContentTypeID=1</link><pubDate>Thu, 24 Feb 2022 10:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f43cadb9-cad8-4d14-a7f0-b0974509e323</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="ISN_B"]I have downloaded the smart remote reference design but do not see where the audio subsystem is implemented. Can you point me to where I should be looking?[/quote]
&lt;p&gt;You can find the audio subsystem in this file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;nRFready Smart Remote 3 nRF52 v1.2.1alpha\nRF5x SDK-SR3\examples\ble_peripheral\smart_remote_3_nrf52\Source\Modules\m_audio.c&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The PDM driver can also be found in:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;nRFready Smart Remote 3 nRF52 v1.2.1alpha\nRF5x SDK-SR3\examples\ble_peripheral\smart_remote_3_nrf52\Source\Drivers\drv_audio_pdm.c&lt;/li&gt;
&lt;/ul&gt;
[quote user="ISN_B"]When I let the program run, I notice that the bufferlength variable I define at the top increments to 0xFFFF though nowhere in the code do I alter the value of bufferlength.[/quote]
&lt;p&gt;Do you mean the&amp;nbsp;buffsize variable? It is possible that your stack size is too small, so the variable gets overwritten. Can you try to declare the buffers and the length variable as static?&lt;/p&gt;
[quote user="ISN_B"]Additionally, since I am only looking to process data locally right now, is there a need to compress the data with the CODEC used in the smart remote reference?[/quote]
&lt;p&gt;Codec is primarily used to reduce the size of the audio transfers over BLE, no need to deal with this if you only want to inspect the audio locally.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/354710?ContentTypeID=1</link><pubDate>Thu, 24 Feb 2022 03:52:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:435ae607-67bc-4346-b14c-6e989c3ad76f</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;digital microphone，what model is it? Is there a purchase link? or&amp;nbsp;pictures;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;thanks&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/354698?ContentTypeID=1</link><pubDate>Wed, 23 Feb 2022 23:58:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:634942c3-b0e5-4d25-a124-d2d7a36e93b0</guid><dc:creator>ISN_B</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have downloaded the smart remote reference design but do not see where the audio subsystem is implemented. Can you point me to where I should be looking?&lt;/p&gt;
&lt;p&gt;I have adjusted the pin numbers to P0.27 for the DATA and P0.26 for the CLK, though I am still facing difficulties obtaining an audio waveform. When I let the program run, I notice that the bufferlength variable I define at the top increments to 0xFFFF though nowhere in the code do I alter the value of bufferlength. The program then encounters a hardfault and stops. The p_buff1 pointer has also changed to&amp;nbsp;0xfff3fffa, which I assume is because the buffer length has increased dramatically somehow.&lt;/p&gt;
&lt;p&gt;Additionally, since I am only looking to process data locally right now, is there a need to compress the data with the CODEC used in the smart remote reference?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/353814?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 11:08:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6188e10-92c1-4cd2-8d42-e89d0589da67</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="ISN_B"]Am I correct to assume that the values in the buffer that I define should be the audio amplitudes?[/quote]
&lt;p&gt;Yes, see the documentation in &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pdm.html#concept_ysq_252_yr"&gt;PDM EasyDMA chapter&lt;/a&gt;.&lt;/p&gt;
[quote user="ISN_B"]From the logic analyzer, I can see that the clock and data pins are streaming[/quote]
&lt;p&gt;Are you using the nRF52840 DK for your testing? I see that you are using P0.05-P0.06 in your code, which by default is used for the UART connection on the DK. Although it looks like you do not enable UART in your firmware, the pins are still connected to the J-Link interface MCU on the DK, so I would advise you to use different GPIOs to avoid potential issues.&lt;/p&gt;
[quote user="ISN_B"]I want to take advantage of Nordic&amp;#39;s provided PDM interface to process this data.[/quote]
&lt;p&gt;I&amp;#39;m not sure if you are aware, but we have a full &lt;a href="https://infocenter.nordicsemi.com/topic/struct_refdesigns/struct/refdesigns_sr3nrf52.html"&gt;smart remote reference design&lt;/a&gt; available, with an&amp;nbsp;&lt;a title="Audio subsystem" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sr3nrf52.firmware/audio.html?cp=15_2_1_2_1"&gt;Audio subsystem&lt;/a&gt;&amp;nbsp;implemented, to capture audio from PDM microphones, and process/code the audio before passing it over BLE. This may be overkill for your purpose, but the firmware is available for reference, and may give you some hints along the way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/353738?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 02:23:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d876884-e000-4b1a-aa23-23dfac6e5f9f</guid><dc:creator>ISN_B</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am trying to record from a digital microphone for a device that will store audio in the device&amp;#39;s flash memory to be processed later on. For right now, I am looking to verify that I can record any sounds from the microphone. I am wondering how I can get the data from the development kit to the computer for processing. I am looking to use a 4kHz sampling rate which I have already configured on the PDM clock. From the logic analyzer, I can see that the clock and data pins are streaming, though I want to take advantage of Nordic&amp;#39;s provided PDM interface to process this data.&lt;/p&gt;
&lt;p&gt;Currently I have been trying to output the bytes from the buffer to a txt file and processing them in MATLAB though the output is pretty much just noise. Am I correct to assume that the values in the buffer that I define should be the audio amplitudes?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/** @file
 * @defgroup uart_example_main main.c
 * @{
 * @ingroup uart_example
 * @brief UART Example Application main file.
 *
 * This file contains the source code for a sample application using UART.
 *
 */

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;nrfx_pdm.h&amp;quot;
#include &amp;quot;nrf_pdm.h&amp;quot;
#include &amp;quot;nrfx_gpiote.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#if defined (UART_PRESENT)
#include &amp;quot;nrf_uart.h&amp;quot;
#endif
#if defined (UARTE_PRESENT)
#include &amp;quot;nrf_uarte.h&amp;quot;
#endif

#define _pin_clk NRF_GPIO_PIN_MAP(0,5)
#define _pin_din NRF_GPIO_PIN_MAP(0,6)

int16_t buff1[1024];
int16_t* p_buff1 = buff1;
uint16_t buffLength = 1024;
int16_t buff2[1024];
bool flag = 0;
bool writeFlag = 0;


//#define ENABLE_LOOPBACK_TEST  /**&amp;lt; if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */

#define MAX_TEST_DATA_BYTES     (15U)                /**&amp;lt; max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 1024                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE 1024                         /**&amp;lt; UART RX buffer size. */

#ifdef ENABLE_LOOPBACK_TEST
/* Use flow control in loopback test. */
#define UART_HWFC APP_UART_FLOW_CONTROL_ENABLED

/** @brief Function for setting the @ref ERROR_PIN high, and then enter an infinite loop.
 */
static void show_error(void)
{

    bsp_board_leds_on();
    while (true)
    {
        // Do nothing.
    }
}


/** @brief Function for testing UART loop back.
 *  @details Transmitts one character at a time to check if the data received from the loopback is same as the transmitted data.
 *  @note  @ref TX_PIN_NUMBER must be connected to @ref RX_PIN_NUMBER)
 */
static void uart_loopback_test()
{
    uint8_t * tx_data = (uint8_t *)(&amp;quot;\r\nLOOPBACK_TEST\r\n&amp;quot;);
    uint8_t   rx_data;

    // Start sending one byte and see if you get the same
    for (uint32_t i = 0; i &amp;lt; MAX_TEST_DATA_BYTES; i++)
    {
        uint32_t err_code;
        while (app_uart_put(tx_data[i]) != NRF_SUCCESS);

        nrf_delay_ms(10);
        err_code = app_uart_get(&amp;amp;rx_data);

        if ((rx_data != tx_data[i]) || (err_code != NRF_SUCCESS))
        {
            show_error();
        }
    }
    return;
}
#else
/* When UART is used for communication with the host do not use flow control.*/
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
#endif

static void drv_pdm_hand(const nrfx_pdm_evt_t *evt){

  nrfx_err_t error = 0;
  if((*evt).buffer_requested){
    
    error = nrfx_pdm_buffer_set(p_buff1, buffLength);
    p_buff1 += buffLength;
  }
  /*if((*evt).buffer_requested){
    if(!flag){
      error = nrfx_pdm_buffer_set(buff1, 1024);
      if(error) {
        printf(&amp;quot;Handler Error1: %d &amp;quot;,error);
      } else{
        printf(&amp;quot;buff1 set &amp;quot;);
      }
      flag = 1;
      writeFlag = 1;
      error = nrfx_pdm_start();
    }
    else{
      error = nrfx_pdm_buffer_set(buff2, 1024);
      if(error) {
        printf(&amp;quot;Handler Error2: %d &amp;quot;,error);
      } else{
        printf(&amp;quot;buff2 set &amp;quot;);
      }
      flag = 0;
      writeFlag = 1;
      error = nrfx_pdm_start();
    }*/
    
}

static void audio_init()
{
  ret_code_t err;
  nrfx_pdm_config_t config1 = NRFX_PDM_DEFAULT_CONFIG(_pin_clk, _pin_din);

  
  nrf_pdm_enable();
  err = nrfx_pdm_init(&amp;amp;config1, drv_pdm_hand);
  APP_ERROR_CHECK(err);

  err = nrfx_pdm_start();
  APP_ERROR_CHECK(err);

}

/**
 * @brief Function for main application entry.
 */
int main(void)
{
    
    audio_init();


    // This part of the example is just for testing the loopback .
    while (true)
    {
    }
}


/** @} */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/PDM-Sound-Plot.jpg" /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/PDM-Output.txt"&gt;devzone.nordicsemi.com/.../PDM-Output.txt&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM Microphone Data Output</title><link>https://devzone.nordicsemi.com/thread/353403?ContentTypeID=1</link><pubDate>Wed, 16 Feb 2022 14:30:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b76dd619-e24f-495c-8b87-d4aec013731d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Not sure I understand your question correctly. Are you asking which interface/peripheral to use to pass the data from the buffer (or flash?) to a PC?&lt;/p&gt;
&lt;p&gt;This will depend on your available connections to the computer, how large throughput you need, and how you will process the data from the buffer on the computer.&lt;/p&gt;
&lt;p&gt;If you can provide some more detail, I can try to give you the best recommendation.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>