<?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>It seems like I&amp;#39;m loosing PCM audio data (decimated from PDM via PDM peripheral on nRF52832 interfacing ST mic) when transmitting the data onto UART.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65541/it-seems-like-i-m-loosing-pcm-audio-data-decimated-from-pdm-via-pdm-peripheral-on-nrf52832-interfacing-st-mic-when-transmitting-the-data-onto-uart</link><description>I&amp;#39;ve interfaced an ST mic eval board (STEVAL-MIC006V1) to the nRF52 dev board on the PDM interface (SDK-15.2.0) . I&amp;#39;m attaching the code for showing my configuration and flow of capturing data and pushing it over UART, for your reference. I just want</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Sep 2020 13:44:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65541/it-seems-like-i-m-loosing-pcm-audio-data-decimated-from-pdm-via-pdm-peripheral-on-nrf52832-interfacing-st-mic-when-transmitting-the-data-onto-uart" /><item><title>RE: It seems like I'm loosing PCM audio data (decimated from PDM via PDM peripheral on nRF52832 interfacing ST mic) when transmitting the data onto UART.</title><link>https://devzone.nordicsemi.com/thread/268555?ContentTypeID=1</link><pubDate>Tue, 08 Sep 2020 13:44:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5018c1e2-4ccf-4d24-bd75-422467a975e6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I don&amp;#39;t know how you would do that. I guess it is not possible to make the PCM output to be equal to a given sequence that you can check when you have received it? Does the received values look reasonable? Does it look like it receives the correct amount of bytes per sample?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: It seems like I'm loosing PCM audio data (decimated from PDM via PDM peripheral on nRF52832 interfacing ST mic) when transmitting the data onto UART.</title><link>https://devzone.nordicsemi.com/thread/268344?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 13:58:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fa37900-a908-44d3-9d5d-fa67ddbc891c</guid><dc:creator>Manish Kaul</dc:creator><description>[quote userid="26071" url="~/f/nordic-q-a/65541/it-seems-like-i-m-loosing-pcm-audio-data-decimated-from-pdm-via-pdm-peripheral-on-nrf52832-interfacing-st-mic-when-transmitting-the-data-onto-uart/268237"]Try to just count the number of bytes received over PDM[/quote]
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1599484634895v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;above, samp value is 162 in 1 second and the Buffsize is 100. samp is incremented at every END event i.e everytime buffer of 100 samples (uint16_t) is filled samp is incremented by 1. Hence if after 1 second I have 162 increments of samp it means there are 162*100=16200 samples in one second, which is equal to PCM output sample frequency.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/65541/it-seems-like-i-m-loosing-pcm-audio-data-decimated-from-pdm-via-pdm-peripheral-on-nrf52832-interfacing-st-mic-when-transmitting-the-data-onto-uart/268237"]How often do you see that these lines prints anything, and what do they print? [/quote]
&lt;p&gt;For some reason it doesn&amp;#39;t enter into the if condition only or it doesn&amp;#39;t check the if condition only.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Anyway I modified the code to transmit data over UART using EasyDMA (UARTE) using Baud rate 460800 and now when I check the byte/sec using the python script it&amp;#39;s coming ~32000.&amp;nbsp;&lt;br /&gt;Modified code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void uart_init(void)
{
    ret_code_t err_code;
    

    nrfx_uarte_config_t config_params = NRFX_UARTE_DEFAULT_CONFIG;
    
    config_params.pselrxd=8;
    config_params.pseltxd=6;
    config_params.baudrate=0x07400000UL; //460800 Baud
    
    err_code=nrfx_uarte_init(&amp;amp;uarte_handler,&amp;amp;config_params,NULL);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    else if (nrf_pdm_event_check(NRF_PDM_EVENT_END))
    {  
        //begin[t]=app_timer_cnt_get();
        //t++;
        nrf_pdm_event_clear(NRF_PDM_EVENT_END);
        j=0;
        //memcpy(audio_sample_copy,audio_sample_buf,sizeof(audio_sample_buf));

        for(uint16_t i=0;i&amp;lt;sizeof(audio_sample_buf)/sizeof(audio_sample_buf[0]);i++)
        {
          audio_uart[j]=(uint8_t)(audio_sample_buf[i]&amp;gt;&amp;gt;8);
          audio_uart[j+1]=(uint8_t)audio_sample_buf[i];

          j+=2;
          //k++;
        }  
        nrfx_uarte_tx(&amp;amp;uarte_handler,(uint8_t*)audio_uart,sizeof(audio_uart));
        

        

    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However, when I try to generate a wav file using the PCM data from serial terminal, I get a highly distorted audio when I playback and the meaningful audio data seems to be superimposed by all the noise/distortion. I also import the raw data from the wave file into an audio app called audacity to playback the audio.&amp;nbsp;&lt;strong&gt;How do I check the correctness of the PCM output from the PDM peripheral&amp;nbsp;?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: It seems like I'm loosing PCM audio data (decimated from PDM via PDM peripheral on nRF52832 interfacing ST mic) when transmitting the data onto UART.</title><link>https://devzone.nordicsemi.com/thread/268237?ContentTypeID=1</link><pubDate>Mon, 07 Sep 2020 09:31:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b031c3cd-c09f-46a4-b9a8-775802976b55</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Ok, let me see if I understand your issue (please correct me if I am wrong).&lt;/p&gt;
&lt;p&gt;You expect to get ~32 000&amp;nbsp;bytes per second, but you see only ~half.&lt;/p&gt;
&lt;p&gt;16 000 bytes = 128 000 bit, so you need to increase the baudrate. 115 200[b/s] is slightly less than 128 000bps, so that gives almost 16 000 bytes per second.Try to increase the baud rate to 1 000 000.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For development purposes, I suggest you wait a bit with the UART. Try to just count the number of bytes received over PDM, and see if you receive the expected 32 000 bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Lastly, I am a bit concerned about your app_uart_put() calls. You don&amp;#39;t check the return values here. What happens if you do something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;err_code = app_uart_put(audio_uart[j]);
if (err_code != NRF_SUCCESS)
{
    NRF_LOG_INFO(&amp;quot;app_uart_put returned 0x%08x&amp;quot;, err_code);
}
err_code = app_uart_put(audio_uart[j+1]);
if (err_code != NRF_SUCCESS)
{
    NRF_LOG_INFO(&amp;quot;app_uart_put returned 0x%08x&amp;quot;, err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How often do you see that these lines prints anything, and what do they print? If it prints &amp;quot;app_uart_put returned 0x00000011&amp;quot;, it means that it returns NRF_ERROR_BUSY, which means that it is already busy processing the previous byte. When this value is retuned, app_uart_put() didn&amp;#39;t successfully queue that byte.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try to do some testing with this in mind. Find out whether all the data is received over PDM, and if so, what is the return value of app_uart_put() when it is not NRF_SUCCESS?&lt;/p&gt;
&lt;p&gt;And you need to increase the UART baudrate. 115200 (from your uart_init() in main.c) is not enough for 32 000bytes/second.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&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: It seems like I'm loosing PCM audio data (decimated from PDM via PDM peripheral on nRF52832 interfacing ST mic) when transmitting the data onto UART.</title><link>https://devzone.nordicsemi.com/thread/267817?ContentTypeID=1</link><pubDate>Thu, 03 Sep 2020 11:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78359033-de16-422e-a6e5-7fb0e09246cb</guid><dc:creator>Manish Kaul</dc:creator><description>&lt;p&gt;I know there&amp;#39;s quite a bit of unnecessary code to my simple application of acquiring data from microphone and receiving them via DMA in RAM and from there send the data to UART at every END event (when allocated space in RAM is filled).&lt;br /&gt;The relevant functions in main.c are the initialization of the pdm_config structure at the top,&amp;nbsp;bsp_event_handler(bsp_event_t event),&amp;nbsp;static void uart_init(void),&amp;nbsp;void buffer_event_handler(nrfx_pdm_evt_t *p_evt),&amp;nbsp;&amp;nbsp;nrfx_pdm_init(&amp;amp;pdm_config,(nrfx_pdm_event_handler_t)buffer_event_handler) under int main().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>