<?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 code implementation and testing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49871/pdm-code-implementation-and-testing</link><description>I have to connect a MIC working on PDM to nrf52 DK Board.For that, I have written the above code. But when I am testing I am not able to get the clock pulses at the defined pin. Also do not know at which Freq it is working? 
 And when I read the pdm documentation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Aug 2019 07:29:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49871/pdm-code-implementation-and-testing" /><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202749?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2019 07:29:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11caa9e6-b7ef-47c7-9c6c-0e41b95e5136</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Thanks a lot, Overbekk and Haakonsh for your support!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202745?ContentTypeID=1</link><pubDate>Wed, 07 Aug 2019 07:15:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7055d7b2-55b9-4558-8435-7e5cfd3e4dd1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;That&amp;#39;s great news, the best of luck with your project &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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202617?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2019 12:39:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2b86aec-9b92-481b-acec-1962a1e3a8f5</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Now able to get data by storing a burst of data in a buffer.&lt;/p&gt;
&lt;p&gt;Thank you so much for your support Overbekk.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202536?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2019 08:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b266421a-00ee-412d-b671-07e25320cf1d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem of printing the data live is that we are talking about a raw data stream of 256kbps.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is technically possible to output on the UART if you use a high baudrate (460800 or more is probably needed), but you will have to display the data as raw data, not as hex. Some terminal programs might be able to show you the data in decimal or hex form, but not all will do this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you considered storing a burst of data in a buffer that you can analyze afterwards?&lt;/p&gt;
&lt;p&gt;Either you can use the debugger to inspect the data in the buffer, or you can output the buffer to UART once you have filled it up (then you don&amp;#39;t have to worry about how much time it takes to empty the buffer, since you are not writing to the UART live).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202399?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2019 11:29:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11cc77d4-a417-42cf-a674-978e22a628a0</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;hello, Ovrebekk.&lt;/p&gt;
&lt;p&gt;I need data because I want to validate the MIC data. Is there any other way to validate PDM MIC data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202318?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2019 07:29:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:616a2401-fea0-4c64-904a-93936c2c2e88</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Thank you soo much Ovrebekk, the code which you gave is working for me now. But now just working on data as I need all the data and printing all the data does not work. So if you have any alternative for it do help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202243?ContentTypeID=1</link><pubDate>Sat, 03 Aug 2019 11:05:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6147d7e-3818-4910-abe7-0b02f3b5f424</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Thank&amp;nbsp; you, initially I had tried with the SDK PDM but in that I was not able to get the clock so I switched with this code. And now out due to weekend so will try out your code on Monday. And if I want all the data then what should I do?? And wich MIC have you interfaced with the nrf52? I have to use the INvensense MIC ICS -41352&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/202205?ContentTypeID=1</link><pubDate>Fri, 02 Aug 2019 15:20:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d1b596a-b7ae-41d1-b84c-52e65765cd7d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sara&lt;/p&gt;
&lt;p&gt;Any particular reason you are not using the PDM driver provided with the SDK?&lt;/p&gt;
&lt;p&gt;I tried to add the PDM driver to the ble_app_uart example, and was able to get it running very quickly. I can print out parts of the PDM data without any issues (I didn&amp;#39;t try to print out all the data, as this might be too much for the UART to handle).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can download my project here if you want to have a look:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-dd5efad0d83b47dabc717543b423faf3/ble_5F00_app_5F00_uart_5F00_pdmtest.zip"&gt;ble_app_uart_pdmtest.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/201821?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2019 11:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dcc73b2-c0cd-4b8c-a72f-6d69f7c94834</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Hi, i had made the interrupt priorities changes as below , but still my device resets and goes into Fatal error.&lt;/p&gt;
&lt;p&gt;#ifndef NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY&lt;br /&gt;#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 5&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;#ifndef PDM_CONFIG_IRQ_PRIORITY&lt;br /&gt;#define PDM_CONFIG_IRQ_PRIORITY 7&lt;br /&gt;#endif&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/201649?ContentTypeID=1</link><pubDate>Wed, 31 Jul 2019 14:32:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:139c2041-0074-446e-8b0d-804b2490e982</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Sara&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think the UART driver is very happy if you try to access the driver from a high priority interrupt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to reduce the interrupt priority of the PDM interrupt handler and see if it works better?&lt;/p&gt;
&lt;p&gt;A higher IRQ priority number corresponds to lower interrupt priority, with 7 being the lowest and 0 the highest.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/201239?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 12:21:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88d8d2a9-20af-480f-a796-3ce5da3f2a6c</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;For me, only the data matters that is how to read the PDM data either on a terminal or from RAM anything will do.You can guide me on either way but need the PDM data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/201233?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 12:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b6e62a6-15f7-454c-87ee-6341804e6842</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Thanks, Torbjorn&lt;/p&gt;
&lt;p&gt;Yes, I want to echo the data which i receive from the PDM which will be PCM data(I guess).&lt;/p&gt;
&lt;p&gt;I was using ble_app_template example code but since I was not getting PDM clock I had removed everything from it and had only kept the PDM related functions.&lt;/p&gt;
&lt;p&gt;For the Uarte code when I had used the code given to me the board was rebooting. But then while I was debugging when I ad only initialised uarte, I got to know it hangs in the while condition of the below code :&lt;/p&gt;
&lt;p&gt;static void serial_tx(void const * p_context, char const * p_buffer, size_t len)&lt;br /&gt;{&lt;br /&gt; uint8_t len8 = (uint8_t)(len &amp;amp; 0x000000FF);&lt;br /&gt; m_xfer_done = false;&lt;br /&gt; ret_code_t err_code = nrf_drv_uart_tx(&amp;amp;m_uart, (uint8_t *)p_buffer, len8);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; /* wait for completion since buffer is reused*/&lt;br /&gt; &lt;strong&gt;while (m_async_mode &amp;amp;&amp;amp; (m_xfer_done == false))&lt;/strong&gt;&lt;br /&gt; {&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;And I am attaching the code when system enters fatal error when I try transmitting data on terminal in PDM handler..&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;ble.h&amp;quot;
#include &amp;quot;ble_hci.h&amp;quot;
#include &amp;quot;ble_srv_common.h&amp;quot;
#include &amp;quot;ble_advdata.h&amp;quot;
#include &amp;quot;ble_advertising.h&amp;quot;
#include &amp;quot;ble_conn_params.h&amp;quot;
#include &amp;quot;nrf_sdh.h&amp;quot;
#include &amp;quot;nrf_sdh_soc.h&amp;quot;
#include &amp;quot;nrf_sdh_ble.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;fds.h&amp;quot;
#include &amp;quot;peer_manager.h&amp;quot;
#include &amp;quot;peer_manager_handler.h&amp;quot;
#include &amp;quot;bsp_btn_ble.h&amp;quot;
#include &amp;quot;sensorsim.h&amp;quot;
#include &amp;quot;ble_conn_state.h&amp;quot;
#include &amp;quot;nrf_ble_gatt.h&amp;quot;
#include &amp;quot;nrf_ble_qwr.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;app_scheduler.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;
#include &amp;quot;app_fifo.h&amp;quot;

#include &amp;quot;nrf_drv_pdm.h&amp;quot;
#include &amp;quot;nrf_fstorage.h&amp;quot;
#include &amp;quot;nrf_fstorage_sd.h&amp;quot;
#include &amp;quot;drv_audio.h&amp;quot;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;nrfx_uarte.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 DEVICE_NAME                     &amp;quot;Nordic_Template&amp;quot;                       /**&amp;lt; Name of device. Will be included in the advertising data. */
#define MANUFACTURER_NAME               &amp;quot;NordicSemiconductor&amp;quot;                   /**&amp;lt; Manufacturer. Will be passed to Device Information Service. */
#define APP_ADV_INTERVAL                 1600//300                                     /**&amp;lt; The advertising interval (in units of 0.625 ms. This value corresponds to 187.5 ms). */

#define APP_ADV_DURATION                500//18000                                   /**&amp;lt; The advertising duration (180 seconds) in units of 10 milliseconds. */
#define APP_BLE_OBSERVER_PRIO           3                                       /**&amp;lt; Application&amp;#39;s BLE observer priority. You shouldn&amp;#39;t need to modify this value. */
#define APP_BLE_CONN_CFG_TAG            1                                       /**&amp;lt; A tag identifying the SoftDevice BLE configuration. */

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(100, UNIT_1_25_MS)        /**&amp;lt; Minimum acceptable connection interval (0.1 seconds). */
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(200, UNIT_1_25_MS)        /**&amp;lt; Maximum acceptable connection interval (0.2 second). */
#define SLAVE_LATENCY                   0                                       /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)         /**&amp;lt; Connection supervisory timeout (4 seconds). */

#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000)                   /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000)                  /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT    3                                       /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */

#define SEC_PARAM_BOND                  1                                       /**&amp;lt; Perform bonding. */
#define SEC_PARAM_MITM                  0                                       /**&amp;lt; Man In The Middle protection not required. */
#define SEC_PARAM_LESC                  0                                       /**&amp;lt; LE Secure Connections not enabled. */
#define SEC_PARAM_KEYPRESS              0                                       /**&amp;lt; Keypress notifications not enabled. */
#define SEC_PARAM_IO_CAPABILITIES       BLE_GAP_IO_CAPS_NONE                    /**&amp;lt; No I/O capabilities. */
#define SEC_PARAM_OOB                   0                                       /**&amp;lt; Out Of Band data not available. */
#define SEC_PARAM_MIN_KEY_SIZE          7                                       /**&amp;lt; Minimum encryption key size. */
#define SEC_PARAM_MAX_KEY_SIZE          16                                      /**&amp;lt; Maximum encryption key size. */

#define DEAD_BEEF                       0xDEADBEEF                              /**&amp;lt; Value used as error code on stack dump, can be used to identify stack location on stack unwind. */
#define UART_TX_BUF_SIZE                256                                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE                256                                         /**&amp;lt; UART RX buffer size. */


#define CONFIG_PDM_BUFFER_SIZE_SAMPLES 64//320

// &amp;lt;o&amp;gt; PDM Decimation Filter Gain &amp;lt;0x00-0x50&amp;gt;
// &amp;lt;i&amp;gt; For details on the PDM decimation filter, see the &amp;#39;Decimation filter&amp;#39; section in the nRF52 Product Specification document.
//#define CONFIG_PDM_GAIN 0x28
//
//
//// &amp;lt;o&amp;gt; PDM CLK Pin
//#define CONFIG_IO_PDM_CLK  29
//
//// &amp;lt;o&amp;gt; PDM DATA Pin
//#define CONFIG_IO_PDM_DATA   5 //0x05

// &amp;lt;o&amp;gt; PDM Microphone Power Control Pin
#define CONFIG_IO_PDM_MIC_PWR_CTRL 0x1A


//
//typedef struct
//{
//    uint8_t buffer[CONFIG_AUDIO_FRAME_SIZE_BYTES];
//    int     buffer_size;
//    bool    buffer_free_flag;
//} drv_audio_frame_t;

unsigned char enabled = 0;
/**@brief Audio buffer handler. */
typedef void (*drv_audio_buffer_handler_t)(int16_t *p_buffer, uint16_t samples);

static int16_t                      input_pdm_buff[2][CONFIG_PDM_BUFFER_SIZE_SAMPLES];
//volatile drv_audio_frame_t       m_audio_frame[CONFIG_AUDIO_FRAME_BUFFERS];

static int32_t                      *output_pdm_buff;
static drv_audio_buffer_handler_t   m_buffer_handler;
//uint16_t			m_frame_index = 0;
//uint16_t                        m_next_frame_index = 0;
static app_sched_event_handler_t        m_audio_frame_handler = NULL;


const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST;
void startDMA();


/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
//nrfx_uarte uarte0 = NRFX_UARTE_INSTANCE(0);

nrfx_uarte_t uarte0 = NRFX_UARTE_INSTANCE(0);
void uarte_handler(nrfx_uarte_event_t const * p_event, void *p)
{
    //Handle uarte events if needed
}

void uarte_init(void)
{
    nrfx_err_t err_code = NRFX_SUCCESS;
    nrfx_uarte_config_t uarte_cfg = NRFX_UARTE_DEFAULT_CONFIG; //Set config in sd_config.h
    
//    err_code = nrfx_uarte_init(&amp;amp;uarte0, &amp;amp;uarte_cfg, uarte_handler);
//    APP_ERROR_CHECK(err_code);
  
//    uint8_t txBuffer[20];
//    uint8_t rxBuffer[20];
//    
//    memset(txBuffer,&amp;#39;A&amp;#39;,sizeof(txBuffer));
//
    NRF_UARTE0-&amp;gt;BAUDRATE = NRF_UARTE_BAUDRATE_115200;
    NRF_UARTE0-&amp;gt;PSEL.TXD = TX_PIN_NUMBER;
    NRF_UARTE0-&amp;gt;PSEL.RXD = RX_PIN_NUMBER;
    NRF_UARTE0-&amp;gt;CONFIG = NRF_UARTE_HWFC_DISABLED;
    NRF_UARTE0-&amp;gt;ENABLE = (UARTE_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; UARTE_ENABLE_ENABLE_Pos);

//    NRF_UARTE0-&amp;gt;TXD.PTR = (uint32_t)((uint8_t *) txBuffer);
//    NRF_UARTE0-&amp;gt;TXD.MAXCNT = sizeof(txBuffer);
//    NRF_UARTE0-&amp;gt;TASKS_STARTTX = 0;
//
//    NRF_UARTE0-&amp;gt;RXD.PTR = (uint32_t)((uint8_t *) rxBuffer);
//    NRF_UARTE0-&amp;gt;RXD.MAXCNT = sizeof(rxBuffer);
//    NRF_UARTE0-&amp;gt;TASKS_STARTRX = 1;
//    NRF_UARTE0-&amp;gt;TASKS_STARTTX = 1;


    NRF_UARTE0-&amp;gt;INTENCLR = 0xFFFFFFFF;
    NRF_UARTE0-&amp;gt;INTENSET = NRF_UARTE_INT_ENDRX_MASK;

    NVIC_ClearPendingIRQ(UARTE0_UART0_IRQn);
    NVIC_SetPriority(UARTE0_UART0_IRQn, 1);
    NVIC_EnableIRQ(UARTE0_UART0_IRQn);
//
//
//    LEDS_CONFIGURE(LEDS_MASK);
//    LEDS_OFF(LEDS_MASK);
//    if(NRF_UARTE0-&amp;gt;EVENTS_RXSTARTED){
//        LEDS_INVERT(1 &amp;lt;&amp;lt; leds_list[1]);
//    }



}


/**@brief Function for initializing the nrf log module.
 */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}




//static void nrf52_pdm_irq(void)
//{
//    // Simply pass on to the driver component handler.
////    if (nrf52_pdm_driver)
////        nrf52_pdm_driver-&amp;gt;irq();
//      irq();
//}

/**
 * Constructor for an instance of a PDM input (typically microphone),
 *
 * @param sd The pin the PDM data input is connected to.
 * @param sck The pin the PDM clock is conected to.
 * @param sampleRate the rate at which samples are generated in the output buffer (in Hz)
 * @param id The id to use for the message bus when transmitting events.
 */
//                


#define BUFFER_SIZE  64

void startDMA()
{

//   NRF_LOG_INFO(&amp;quot;startDMA   \n&amp;quot;);   
   NRF_PDM-&amp;gt;SAMPLE.PTR = (uint32_t)&amp;amp;input_pdm_buff[0];
}

void pdm_enable()
{
    if (!enabled)
    {
        enabled = true;

        NRF_PDM-&amp;gt;ENABLE = 1;

        startDMA();

        NRF_PDM-&amp;gt;TASKS_START = 1;
//        NRF_PDM-&amp;gt;EVENTS_STARTED = 1;
    }
}

/**
 * Disable this component
 */
void pdm_disable()
{
    // Schedule all DMA transfers to stop after the next DMA transaction completes.
    enabled = false;
    NRF_PDM-&amp;gt;ENABLE = 0;
//    NRF_PDM-&amp;gt;TASKS_START = 1;
//    NRF_PDM-&amp;gt;EVENTS_STOPPED = 0;
//    NRF_PDM_TASK_STOP = 0;
}



void PDM_IRQHandler()
{

//    NRF_LOG_INFO(&amp;quot; INTERRUPT HANDLER \n&amp;quot;); 
    if (NRF_PDM-&amp;gt;EVENTS_STARTED) 
    {
//         NRF_LOG_INFO(&amp;quot; EVENTS_STARTED \n&amp;quot;); 
        // We&amp;#39;ve just started receiving data the inputBuffer.
        // So we don&amp;#39;t miss any data, line up the next buffer.
        // (unless we&amp;#39;ve been asked to stop).
        if (enabled)
        {
          uint16_t *finished_buffer;
          finished_buffer = input_pdm_buff[0];
          nrfx_uarte_tx(&amp;amp;uarte0, &amp;amp;input_pdm_buff, CONFIG_AUDIO_FRAME_SIZE_BYTES);
          startDMA();

          NRF_PDM-&amp;gt;EVENTS_STARTED = 0;
        }
    }

    if (NRF_PDM-&amp;gt;EVENTS_END)
    {
//      NRF_LOG_INFO(&amp;quot; EVENTS_END \n&amp;quot;); 
//        if (outputBuffer.length() &amp;gt; 0)
//            output.pullRequest();

        NRF_PDM-&amp;gt;EVENTS_END = 0;
    }

    if (NRF_PDM-&amp;gt;EVENTS_STOPPED)
    NRF_LOG_INFO(&amp;quot; EVENTS_STOPPED \n&amp;quot;); 
        NRF_PDM-&amp;gt;EVENTS_STOPPED = 0;

    // Erratum.
    // JF: Not sure what this is working around? Seems harmless, so leaving it in for now...
    (void) NRF_PDM-&amp;gt;EVENTS_STOPPED;
    
}

void pdm_init()
{
   
    // Define our output stream as non-bocking.
//    output.setBlocking(false);

   
    pdm_disable();
  
    nrf_gpio_cfg_output(CONFIG_IO_PDM_CLK);
    nrf_gpio_cfg_input(CONFIG_IO_PDM_DATA,NRF_GPIO_PIN_NOPULL);

    // Map the PDM peripheral onto the given pins...
    NRF_PDM-&amp;gt;PSEL.CLK = CONFIG_IO_PDM_CLK;
//    pdm_cfg.edge = NRF_PDM_EDGE_LEFTRISING;
//   nrf_pdm_mode_set(nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge)

     NRF_PDM-&amp;gt;MODE = ((PDM_CONFIG_MODE &amp;lt;&amp;lt; PDM_MODE_OPERATION_Pos) &amp;amp; PDM_MODE_OPERATION_Msk)
                    | ((NRF_PDM_EDGE_LEFTRISING &amp;lt;&amp;lt; PDM_MODE_EDGE_Pos) &amp;amp; PDM_MODE_EDGE_Msk);


    NRF_PDM-&amp;gt;PSEL.DIN = CONFIG_IO_PDM_DATA;

    // Configure for DMA enabled, single channel PDM input.
//  NVIC_SetVector(PDM_IRQn, (uint32_t )nrf52_pdm_irq);

    /* Set up interrupts */
    NRF_PDM-&amp;gt;INTENSET = (PDM_INTENSET_STARTED_Enabled &amp;lt;&amp;lt; PDM_INTENSET_STARTED_Pos) |
        (PDM_INTENSET_END_Enabled &amp;lt;&amp;lt; PDM_INTENSET_END_Pos ) |
        (PDM_INTENSET_STOPPED_Enabled &amp;lt;&amp;lt; PDM_INTENSET_STOPPED_Pos);

    NVIC_SetPriority( PDM_IRQn, 1);
    NVIC_ClearPendingIRQ( PDM_IRQn );
    NVIC_EnableIRQ( PDM_IRQn );


    // Configure for a 1.032MHz PDM clock.
    NRF_PDM-&amp;gt;PDMCLKCTRL = (PDM_PDMCLKCTRL_FREQ_Default &amp;lt;&amp;lt; PDM_PDMCLKCTRL_FREQ_Pos );

    // Mono operation.
    NRF_PDM-&amp;gt;MODE = ( PDM_MODE_EDGE_LeftRising  &amp;lt;&amp;lt; PDM_MODE_EDGE_Pos ) |
        (PDM_MODE_OPERATION_Mono &amp;lt;&amp;lt; PDM_MODE_OPERATION_Pos);

    // Set default gain of 0dbm.
    NRF_PDM-&amp;gt;GAINL = CONFIG_AUDIO_PDM_GAIN;
    NRF_PDM-&amp;gt;GAINR = CONFIG_AUDIO_PDM_GAIN;


    // Configure buffer size.
   
    NRF_PDM-&amp;gt;SAMPLE.PTR = (uint32_t)&amp;amp;input_pdm_buff[0];
    NRF_PDM-&amp;gt;SAMPLE.MAXCNT = CONFIG_PDM_BUFFER_SIZE_SAMPLES;
    pdm_enable();

    // Record our sample rate for future computation.
    // This is a constant of the PDM samplerate / 64 (as defined in nrf52 specification, seciton 44).
    // For the configuration above, this translates to approx 16kHz.
//    this-&amp;gt;sampleRate = 1032000 / 64;
}



   




/**
 * Initiate a DMA transfer into the raw data buffer.
 */

static void idle_state_handle(void)
{
    if (NRF_LOG_PROCESS() == false)
    {
        nrf_pwr_mgmt_run();
    }
}


/**@brief Function for application main entry.
 */
int main(void)
{
   // Start execution.

 
    log_init();
//

    uarte_init();
//      uart_init();

    NRF_LOG_INFO(&amp;quot;Template example started.&amp;quot;);
    pdm_init();
    

for (;;)
    {
        idle_state_handle();
    }
  
}




/**
 * Update our reference to a downstream component.
 * Pass through any connect requests to our output buffer component.
 *
 * @param component The new downstream component for this PDM audio source.
 */


//static NRF52PDM *nrf52_pdm_driver = NULL;





&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/201222?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 11:46:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8c4088f-ae3a-4051-ad47-ab4ce64ec6ce</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Håkon is currently out in vacation, and I will help out with your case in the meantime.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I understand correctly you simply want to echo all the data you receive over the PWM onto the UART interface?&lt;/p&gt;
&lt;p&gt;If so I agree with Håkon&amp;#39;s suggestion above to use the nrfx_uarte driver, except&amp;nbsp;that the uarte_handler function is implemented incorrectly in his code snippet. It should look like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void uarte_handler(nrfx_uarte_event_t const * p_event, void *p)
{
    //Handle uarte events if needed
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can you send me the code snippet that makes the system reset?&lt;/p&gt;
&lt;p&gt;Are you using the template project in the SDK as the starting point, or something else?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200920?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 09:24:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fe7fdb2-a20f-4d44-8ee4-d285f400dead</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;For your reference,&lt;pre class="ui-code" data-mode="text"&gt;static int16_t                      input_pdm_buff[2][CONFIG_PDM_BUFFER_SIZE_SAMPLES];
//volatile drv_audio_frame_t       m_audio_frame[CONFIG_AUDIO_FRAME_BUFFERS];

static int32_t                      *output_pdm_buff;
static drv_audio_buffer_handler_t   m_buffer_handler;
//uint16_t			m_frame_index = 0;
//uint16_t                        m_next_frame_index = 0;
static app_sched_event_handler_t        m_audio_frame_handler = NULL;


const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST;


//void UARTE0_UART0_IRQHandler(){
//
//    if(NRF_UARTE0-&amp;gt;EVENTS_ENDRX){
//        LEDS_INVERT(1 &amp;lt;&amp;lt; leds_list[3]);
//    }
//
//}




/**@brief   Function for handling app_uart events.
 *
 * @details This function will receive a single character from the app_uart module and append it to
 *          a string. The string will be be sent over BLE when the last character received was a
 *          &amp;#39;new line&amp;#39; &amp;#39;\n&amp;#39; (hex 0x0A) or if the string has reached the maximum data length.
 */
/**@snippet [Handling the data received over UART] */
void uart_event_handle(app_uart_evt_t * p_event)
{
    static uint8_t data_array[CONFIG_PDM_BUFFER_SIZE_SAMPLES];
    static uint8_t index = 0;
    uint32_t       err_code;

    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
            index++;

            if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) ||
                (data_array[index - 1] == &amp;#39;\r&amp;#39;) ||
                (index &amp;gt;= CONFIG_PDM_BUFFER_SIZE_SAMPLES))
            {
                if (index &amp;gt; 1)
                {
                    NRF_LOG_DEBUG(&amp;quot;Ready to send data over BLE NUS&amp;quot;);
                    NRF_LOG_HEXDUMP_DEBUG(data_array, index);

//                    do
//                    {
//                        uint16_t length = (uint16_t)index;
//                        err_code = ble_nus_data_send(&amp;amp;m_nus, data_array, &amp;amp;length, m_conn_handle);
//                        if ((err_code != NRF_ERROR_INVALID_STATE) &amp;amp;&amp;amp;
//                            (err_code != NRF_ERROR_RESOURCES) &amp;amp;&amp;amp;
//                            (err_code != NRF_ERROR_NOT_FOUND))
//                        {
//                            APP_ERROR_CHECK(err_code);
//                        }
//                    } while (err_code == NRF_ERROR_RESOURCES);
                }

                index = 0;
            }
            break;

        case APP_UART_COMMUNICATION_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            break;

        case APP_UART_FIFO_ERROR:
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            break;

        default:
            break;
    }
}
/**@snippet [Handling the data received over UART] */



/**@brief  Function for initializing the UART module.
 */
/**@snippet [UART Initialization] */
//nrfx_uarte uarte0 = NRFX_UARTE_INSTANCE(0);

nrfx_uarte_t uarte0 = NRFX_UARTE_INSTANCE(0);
void uarte_handler(nrfx_uarte_evt_type_t evt)
{
    //Handle uarte events if needed
}

void uarte_init(void)
{
    nrfx_err_t err_code = NRFX_SUCCESS;
    nrfx_uarte_config_t uarte_cfg = NRFX_UARTE_DEFAULT_CONFIG; //Set config in sd_config.h
    
//    err_code = nrfx_uarte_init(&amp;amp;uarte0, &amp;amp;uarte_cfg, uarte_handler);
//    APP_ERROR_CHECK(err_code);
  
//    uint8_t txBuffer[20];
//    uint8_t rxBuffer[20];
//    
//    memset(txBuffer,&amp;#39;A&amp;#39;,sizeof(txBuffer));
//
    NRF_UARTE0-&amp;gt;BAUDRATE = NRF_UARTE_BAUDRATE_115200;
    NRF_UARTE0-&amp;gt;PSEL.TXD = TX_PIN_NUMBER;
    NRF_UARTE0-&amp;gt;PSEL.RXD = RX_PIN_NUMBER;
    NRF_UARTE0-&amp;gt;CONFIG = NRF_UARTE_HWFC_DISABLED;
    NRF_UARTE0-&amp;gt;ENABLE = (UARTE_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; UARTE_ENABLE_ENABLE_Pos);

//    NRF_UARTE0-&amp;gt;TXD.PTR = (uint32_t)((uint8_t *) txBuffer);
//    NRF_UARTE0-&amp;gt;TXD.MAXCNT = sizeof(txBuffer);
//    NRF_UARTE0-&amp;gt;TASKS_STARTTX = 0;
//
//    NRF_UARTE0-&amp;gt;RXD.PTR = (uint32_t)((uint8_t *) rxBuffer);
//    NRF_UARTE0-&amp;gt;RXD.MAXCNT = sizeof(rxBuffer);
//    NRF_UARTE0-&amp;gt;TASKS_STARTRX = 1;
//    NRF_UARTE0-&amp;gt;TASKS_STARTTX = 1;


    NRF_UARTE0-&amp;gt;INTENCLR = 0xFFFFFFFF;
    NRF_UARTE0-&amp;gt;INTENSET = NRF_UARTE_INT_ENDRX_MASK;

    NVIC_ClearPendingIRQ(UARTE0_UART0_IRQn);
    NVIC_SetPriority(UARTE0_UART0_IRQn, 1);
    NVIC_EnableIRQ(UARTE0_UART0_IRQn);
//
//
//    LEDS_CONFIGURE(LEDS_MASK);
//    LEDS_OFF(LEDS_MASK);
//    if(NRF_UARTE0-&amp;gt;EVENTS_RXSTARTED){
//        LEDS_INVERT(1 &amp;lt;&amp;lt; leds_list[1]);
//    }



}


/**@brief Function for initializing the nrf log module.
 */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}




//static void nrf52_pdm_irq(void)
//{
//    // Simply pass on to the driver component handler.
////    if (nrf52_pdm_driver)
////        nrf52_pdm_driver-&amp;gt;irq();
//      irq();
//}

/**
 * Constructor for an instance of a PDM input (typically microphone),
 *
 * @param sd The pin the PDM data input is connected to.
 * @param sck The pin the PDM clock is conected to.
 * @param sampleRate the rate at which samples are generated in the output buffer (in Hz)
 * @param id The id to use for the message bus when transmitting events.
 */
//                


#define BUFFER_SIZE  64

  typedef struct ArrayList
  {
    uint8_t buffer[BUFFER_SIZE];
  } ArrayList_type;

 


void startDMA()
{

//    ArrayList_type ReaderList[63];
//      uint32_t i;
////    PDMREADER.MAXCNT = BUFFER_SIZE;
////    READER.PTR = &amp;amp;ReaderList;
////    PDM_SAMPLE_PTR_SAMPLEPTR_Pos 
//    NRF_PDM-&amp;gt;SAMPLE.MAXCNT = BUFFER_SIZE;
//    NRF_PDM-&amp;gt;SAMPLE.PTR = &amp;amp;ReaderList;
//    for(i=0;i&amp;lt;BUFFER_SIZE;i++)
//   {
//      NRF_LOG_INFO(&amp;quot;ReaderList[%d] = %d &amp;quot;,i,ReaderList-&amp;gt;buffer[i]);
//
//   }

//    uint32_t err_code;
//    err_code = drv_audio_init(m_audio_handler);
//    APP_ERROR_CHECK(err_code);


//    output_pdm_buff = &amp;amp;input_pdm_buff[0];
    uint32_t i;
    NRF_LOG_INFO(&amp;quot;startDMA   \n&amp;quot;);
//
//   
   NRF_PDM-&amp;gt;SAMPLE.PTR = (uint32_t)&amp;amp;input_pdm_buff[0];
//   NRF_LOG_INFO(&amp;quot;NRF_PDM-&amp;gt;SAMPLE.PTR   =  %x &amp;quot;,NRF_PDM-&amp;gt;SAMPLE.PTR );
   memcpy(output_pdm_buff, &amp;amp;input_pdm_buff[0],CONFIG_PDM_BUFFER_SIZE_SAMPLES);
   
//     for(i=0;i&amp;lt;CONFIG_PDM_BUFFER_SIZE_SAMPLES;i++)
//     {
//      NRF_LOG_INFO(&amp;quot;m_audio_frame-&amp;gt;buffer[%d] = %d &amp;quot;,i,output_pdm_buff[i]);
//
//
//     }



//     drv_audio_frame_t *p_frame;
//     app_sched_event_put(&amp;amp;p_frame, sizeof(drv_audio_frame_t *), m_audio_frame_handler);
//    NRF_PDM-&amp;gt;SAMPLE.PTR = (uint32_t)&amp;amp;m_audio_frame[0];
//     memcpy(&amp;amp;(m_audio_frame-&amp;gt;buffer), p_frame,CONFIG_AUDIO_FRAME_SIZE_BYTES);
//     uint32_t i;
//     for(i=0;i&amp;lt;CONFIG_AUDIO_FRAME_SIZE_BYTES;i++)
//     {
//      NRF_LOG_INFO(&amp;quot;m_audio_frame-&amp;gt;buffer[%d] = %d &amp;quot;,i,m_audio_frame-&amp;gt;buffer[i]);
//
//
//     }


}
//
//
///**
// * Enable this component
// */
void pdm_enable()
{
    if (!enabled)
    {
        enabled = true;

        NRF_PDM-&amp;gt;ENABLE = 1;

//        pdm_start();
//        startDMA();

        NRF_PDM-&amp;gt;TASKS_START = 1;
    }
}

/**
 * Disable this component
 */
void pdm_disable()
{
    // Schedule all DMA transfers to stop after the next DMA transaction completes.
    enabled = false;
    NRF_PDM-&amp;gt;ENABLE = 0;
}


void PDM_IRQHandler()
{
   
    if (NRF_PDM-&amp;gt;EVENTS_STARTED) 
    {
        // We&amp;#39;ve just started receiving data the inputBuffer.
        // So we don&amp;#39;t miss any data, line up the next buffer.
        // (unless we&amp;#39;ve been asked to stop).
//        m_xfer_done = true;
        nrfx_uarte_tx(&amp;amp;uarte0, &amp;amp;input_pdm_buff, CONFIG_AUDIO_FRAME_SIZE_BYTES);
        
          
        if (enabled)

        startDMA();

        NRF_PDM-&amp;gt;EVENTS_STARTED = 0;
    }

    if (NRF_PDM-&amp;gt;EVENTS_END)
    {
//        if (outputBuffer.length() &amp;gt; 0)
//            output.pullRequest();

        NRF_PDM-&amp;gt;EVENTS_END = 0;
    }

    if (NRF_PDM-&amp;gt;EVENTS_STOPPED)
        NRF_PDM-&amp;gt;EVENTS_STOPPED = 0;

    // Erratum.
    // JF: Not sure what this is working around? Seems harmless, so leaving it in for now...
    (void) NRF_PDM-&amp;gt;EVENTS_STOPPED;




    
}




void pdm_init()
{
   
    // Define our output stream as non-bocking.
//    output.setBlocking(false);

   
    pdm_disable();
  
    nrf_gpio_cfg_output(CONFIG_IO_PDM_CLK);
    nrf_gpio_cfg_input(CONFIG_IO_PDM_DATA,NRF_GPIO_PIN_NOPULL);

    // Map the PDM peripheral onto the given pins...
    NRF_PDM-&amp;gt;PSEL.CLK = CONFIG_IO_PDM_CLK;
//    pdm_cfg.edge = NRF_PDM_EDGE_LEFTRISING;
//   nrf_pdm_mode_set(nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge)

     NRF_PDM-&amp;gt;MODE = ((PDM_CONFIG_MODE &amp;lt;&amp;lt; PDM_MODE_OPERATION_Pos) &amp;amp; PDM_MODE_OPERATION_Msk)
                    | ((NRF_PDM_EDGE_LEFTRISING &amp;lt;&amp;lt; PDM_MODE_EDGE_Pos) &amp;amp; PDM_MODE_EDGE_Msk);


    NRF_PDM-&amp;gt;PSEL.DIN = CONFIG_IO_PDM_DATA;

    // Configure for DMA enabled, single channel PDM input.
//  NVIC_SetVector(PDM_IRQn, (uint32_t )nrf52_pdm_irq);

    /* Set up interrupts */
    NRF_PDM-&amp;gt;INTENSET = (PDM_INTENSET_STARTED_Enabled &amp;lt;&amp;lt; PDM_INTENSET_STARTED_Pos) |
        (PDM_INTENSET_END_Enabled &amp;lt;&amp;lt; PDM_INTENSET_END_Pos ) |
        (PDM_INTENSET_STOPPED_Enabled &amp;lt;&amp;lt; PDM_INTENSET_STOPPED_Pos);

    NVIC_SetPriority( PDM_IRQn, 1);
    NVIC_ClearPendingIRQ( PDM_IRQn );
    NVIC_EnableIRQ( PDM_IRQn );


    // Configure for a 1.032MHz PDM clock.
    NRF_PDM-&amp;gt;PDMCLKCTRL = (PDM_PDMCLKCTRL_FREQ_Default &amp;lt;&amp;lt; PDM_PDMCLKCTRL_FREQ_Pos );

    // Mono operation.
    NRF_PDM-&amp;gt;MODE = ( PDM_MODE_EDGE_LeftRising  &amp;lt;&amp;lt; PDM_MODE_EDGE_Pos ) |
        (PDM_MODE_OPERATION_Mono &amp;lt;&amp;lt; PDM_MODE_OPERATION_Pos);

    // Set default gain of 0dbm.
    NRF_PDM-&amp;gt;GAINL = CONFIG_AUDIO_PDM_GAIN;
    NRF_PDM-&amp;gt;GAINR = CONFIG_AUDIO_PDM_GAIN;


    // Configure buffer size.
   
    NRF_PDM-&amp;gt;SAMPLE.PTR = &amp;amp;input_pdm_buff[0];
    NRF_PDM-&amp;gt;SAMPLE.MAXCNT = CONFIG_PDM_BUFFER_SIZE_SAMPLES;
    pdm_enable();

    // Record our sample rate for future computation.
    // This is a constant of the PDM samplerate / 64 (as defined in nrf52 specification, seciton 44).
    // For the configuration above, this translates to approx 16kHz.
//    this-&amp;gt;sampleRate = 1032000 / 64;
}



   




/**
 * Initiate a DMA transfer into the raw data buffer.
 */

static void idle_state_handle(void)
{
    if (NRF_LOG_PROCESS() == false)
    {
        nrf_pwr_mgmt_run();
    }
}


/**@brief Function for application main entry.
 */
int main(void)
{
   // Start execution.

 
    log_init();
//

    uarte_init();
//      uart_init();

    NRF_LOG_INFO(&amp;quot;Template example started.&amp;quot;);
    pdm_init();
    

for (;;)
    {
        idle_state_handle();
    }
  
}

&lt;/pre&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0456.sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../0456.sdk_5F00_config.h&lt;/a&gt; I am attaching my code and sdk_config.h file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200830?ContentTypeID=1</link><pubDate>Sat, 27 Jul 2019 04:34:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80501b0e-aad8-45bb-bbed-1c74668ee916</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Is there any other way how can I get the EasyDMA data or PDM data ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200754?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 11:54:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:111c159b-dcd8-4b59-b19f-e90a0de05027</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Thanks, But when I call&amp;nbsp;uarte_init(); in main the system resets&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200717?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 10:29:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd605d52-fbb8-4211-9c3a-1f56b58e20c5</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Once a set of samples are taken they have already been transferred to RAM via EasyDMA. If you want to send this over UART to a terminal you need to start a UART&lt;strong&gt;E&lt;/strong&gt; transfer where the TX buffer pointer points to the PDM buffer.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;See&amp;nbsp;&lt;a title="UARTE driver" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__uarte.html?cp=5_1_6_9_0_40_0"&gt;UARTE driver&lt;/a&gt;&amp;nbsp;API docs:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrfx_uarte uarte0 = NRFX_UARTE_INSTANCE(0);

void uarte_handler(nrfx_uarte_evt_type_t evt)
{
    //Handle uarte events if needed
}

void uarte_init(void)
{
    nrfx_err_t err_code = NRFX_SUCCESS;
    nrfx_uarte_config_t uarte_cfg = NRFX_UARTE_DEFAULT_CONFIG; //Set config in sd_config.h
    
    err_code = nrfx_uarte_init(&amp;amp;uarte0, &amp;amp;uarte_cfg, uarte_handler);
    APP_ERROR_CHECK(err_code);
}

// In PDM handler, call: nrfx_uarte_tx(&amp;amp;uarte0, &amp;amp;YourPDMbuffer, LenghtOfPDMbuffer)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200649?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 06:36:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61a59680-7054-48ce-bf5c-06f517fb8e53</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Hello Haakonsh, I got the pdm clock but now how should I print the PDM data on terminal using easyDMA?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200103?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 13:56:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9d1c3d0-b8b5-477c-af3f-bf008c7cf862</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Call&amp;nbsp;&lt;a title="nrfx_clock_init" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__clock.html?cp=5_1_6_9_0_3_1_11#gade48f50b80f5acb42513d31e9e58c9f7"&gt;nrfx_clock_init&lt;/a&gt;, then&amp;nbsp;&lt;a title="nrfx_clock_hfclk_start" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__clock.html?cp=5_1_6_9_0_3_1_9#ga47ae505a8d02b012d1bb881b2a83c7f1"&gt;nrfx_clock_hfclk_start&lt;/a&gt;, then wait for the&amp;nbsp;&lt;a title="EVENTS_HFCLKSTARTED" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/clock.html?cp=3_0_0_4_3_2_7#register.EVENTS_HFCLKSTARTED"&gt;EVENTS_HFCLKSTARTED&lt;/a&gt;&amp;nbsp;event:&lt;br /&gt;while(!NRF_CLOCK-&amp;gt;&lt;span&gt;EVENTS_HFCLKSTARTED&lt;/span&gt;)();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200078?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 13:21:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b138dd42-efb3-43ee-b04f-24597a7c0d40</guid><dc:creator>sara</dc:creator><description>&lt;ol&gt;
&lt;li&gt;Ok n if no softdevice is enabled then sd_clock_hflck_request should not be enabled for PDM init . Am I ryt?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/200061?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 12:50:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c07306f7-a99b-4e2f-b9c7-0a73caf8a905</guid><dc:creator>haakonsh</dc:creator><description>&lt;ol&gt;
&lt;li&gt;&amp;nbsp;See&amp;nbsp;&lt;a title="sd_clock_hfclk_request" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.1.1/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html?cp=3_4_2_1_2_7_2_3#ga3e5afb495a1b0307c749cc268df94a74"&gt;sd_clock_hfclk_request&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;No you do not need to init another peripheral.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;You need to call&amp;nbsp;&lt;/span&gt;&lt;a title="nrfx_pdm_start" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__pdm.html?cp=5_1_6_9_0_19_1_9#ga296fabdbaca15179a54777be2d6b38a9"&gt;nrfx_pdm_start&lt;/a&gt;&lt;span&gt;&amp;nbsp;after&amp;nbsp;&lt;/span&gt;&lt;a title="nrfx_pdm_init" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__pdm.html?cp=5_1_6_9_0_19_1_8#gaa57ad2808b90d8236ebad625af2c5c30"&gt;nrfx_pdm_init&lt;/a&gt;&lt;span&gt;&amp;nbsp;i guess.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/199919?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 06:18:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:231a4a94-624b-47e2-bb42-03aaa73c8fc7</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;1) And what does this mean given in the datasheet of nrf52832 &amp;quot; &lt;strong&gt;&lt;span class="fontstyle0"&gt;43.1 Master clock generator&lt;br /&gt;&lt;/span&gt;&lt;span class="fontstyle2"&gt;The FREQ field in the master clock&amp;#39;s PDMCLKCTRL register allows adjusting the PDM clock&amp;#39;s frequency.&lt;br /&gt;The master clock generator does not add any jitter to the HFCLK source chosen. It is recommended (but not&lt;br /&gt;mandatory) to use the Xtal as HFCLK source&lt;/span&gt;&amp;nbsp;&amp;quot;&amp;nbsp;&lt;/strong&gt;Do I need to set HFCLK ? and if yes then how?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2) And do I need to init any other interface ? I2C ?or any peripherals?&lt;/p&gt;
&lt;p&gt;3) After pdm_init is called will I get the clock pulse?(If yes, then I am not getting clock pulse even after nrf_drv_pdm_init() )&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/199912?ContentTypeID=1</link><pubDate>Tue, 23 Jul 2019 05:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9588a1a-86fb-4435-a02e-c2c8a1fa40ab</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;yes, I am sure I am measuring on the pin p0.29. And its toggling. I have attached the screenshot for it.&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4604.image2.png" /&gt;&lt;/p&gt;
&lt;p&gt;And one more thing what is the use of&amp;nbsp;CONFIG_IO_PDM_MIC_PWR_CTRL pin ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/199799?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 12:50:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c462506f-829a-4fff-926d-75ccd9b9ccfd</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Are you sure you&amp;#39;re measuring for the clock signal on p0.29 of the PCA10040 DK?&lt;br /&gt;&lt;br /&gt;Are you able to toggle the pin state of p0.29 with a call to&amp;nbsp;&lt;a title="nrf_gpio_cfg_output" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__gpio__hal.html?cp=5_1_6_9_0_11_0_9#ga5c6f584e6e01dd0c65bd1b9eee958cbb"&gt;nrf_gpio_cfg_output&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a title="nrf_gpio_pin_toggle" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__gpio__hal.html?cp=5_1_6_9_0_11_0_23#gac7f7bf539f5bb053b4a313ec51d8157e"&gt;nrf_gpio_pin_toggle&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM code implementation and testing</title><link>https://devzone.nordicsemi.com/thread/199711?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2019 09:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53d060db-3262-4fbe-94e8-0fb46f3e7d8f</guid><dc:creator>sara</dc:creator><description>&lt;p&gt;Hello Haakonsh, Please suggest me what next should I do to make my pdm driver work. As still I am not able to get the clock on CRO, which means pdm is not configured properly (I guess).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>