<?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>DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106831/dmic-pop-click-sounds-between-each-memory-block</link><description>I&amp;#39;m trying to continuously stream data from the dmic interface, in this case over serial though only for testing. Things seem to be largely working except for pop/click artifacts between every block. In this case the memory slab is setup for 4 blocks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Jan 2024 09:00:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106831/dmic-pop-click-sounds-between-each-memory-block" /><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/463926?ContentTypeID=1</link><pubDate>Fri, 12 Jan 2024 09:00:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa2ea980-8d7a-490b-87b0-ff2c97ffbb31</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;Very good to hear that this fixed the issue &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;If you look into the exact timings of the printk calls maybe you would find when they start to lag too much behind the DMIC operation to cause issues. I understand the desire to fully understand what is happening, but it is probably not worth the investment in time in this case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The best of luck with your project!&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/463809?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2024 15:09:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa774ab7-7a51-49a9-bcdf-d0beffd69478</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Hi Torbj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;that is really interesting and yes it does fix the issue!&lt;br /&gt;I&amp;#39;m a bit puzzled as that means something works very differently than I thought with the dmic driver but I&amp;#39;m glad to know that I can ensure things stream correctly if there is definitely no bandwidth bottleneck.&lt;br /&gt;There is that &amp;quot;starting pop&amp;quot; still but that is fine and seems to be what the Thingy:53 firmware mentioned.&lt;br /&gt;Also good to know that UART is not async by default&lt;br /&gt;&lt;br /&gt;Thank you for looking at this so thoroughly, it&amp;#39;s much appreciated!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704985230670v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/463741?ContentTypeID=1</link><pubDate>Thu, 11 Jan 2024 12:39:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e796c764-3f4f-4d25-923b-9ca9e05b1ad9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;I did some tests myself in order to evaluate the performance of the UART communication.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Trying out the code you sent me&amp;nbsp;I connected the logic analyzer to the TX line in order to see if there could be any issues with the&amp;nbsp;UART communication, and the results were interesting:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704974016609v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;After every byte I see a gap of around 3.5us, which means the overall throughput will be reduced by a significant factor.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Exactly why this happens I am not sure, but I wouldn&amp;#39;t be surprised if the console driver (printk) sends data to the underlying transport layer (UART in this case) byte by byte, which means the UART driver is not able to buffer multiple bytes in one transaction.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did a quick rewrite of the code integrating a more efficient UART layer, utilizing the UART async driver&amp;nbsp;to send larger buffers in one go, and now communication seems more efficient:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704974756449v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704974798526v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Most bytes are sent back to back, except for a ~35us delay when switching from one buffer to the next.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is a larger delay every 100ms which I assume shows that the&amp;nbsp;bandwidth is now more than sufficient to send the data in time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you try out my code and see if it solves the glitching issue?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/319611_5F00_dmic_5F00_issue.zip"&gt;devzone.nordicsemi.com/.../319611_5F00_dmic_5F00_issue.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please note I use a wrapper for the UART async driver called &amp;#39;app_uart&amp;#39; in order to simplify the UART interface, but everything is included in the repo. In order to track my changes you can&amp;nbsp;check the git log.&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/463416?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 16:59:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34d16a11-1a17-4f36-9176-1e0716c82d46</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Yea I can hook up a Saleae but need to check if there are usable test points. the uart is read out via the onboard debugger.&lt;br /&gt;Ultimately I want to send the audio samples via BLE GATT (BLE audio is not well enough supported by other devices and not necessary for this application, the samples will be processed by software), while it would be really helpful for development to have some other way to send out sample data to debug I would mostly care about ensuring that you can actually stream DMIC data &amp;quot;easily&amp;quot;, the current issue worries me a bit that this is going to very finicky to avoid such artifacts.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m sceptical that the UART is the problem here because of the following observation and assumptions.&lt;br /&gt;The dmic peripheral is provided 4 memory blocks to use for sampling. Sampling is done via DMA so user code should not be blocking the dmic peripheral from continuing to fill up the next free block with sample data. Only when all 4 blocks are exhausted and not freed by the user should the user code become a bottleneck but the clicks appear after the very first block.&lt;br /&gt;If I would miss sample data after the 4th block it would be fair to assume that we can&amp;#39;t keep up with freeing memory blocks fast enough to provide free blocks to the dmic peripheral.&lt;/p&gt;
&lt;p&gt;Which leads me to assume that there is either something that needs to be done to correctly join blocks of sample data and my naive way of just appending it all is not correct or that there is something wrong in the way I setup the dmic peripheral that it maybe resets something with each block read.&lt;br /&gt;I saw a reference in the firmware for the Thingy:53 of avoiding a click sound when starting with the sampling but not specifics as to what the reason for that artifact is. I do observe that the samples need to settle for a few ms, there is a consistent observable &amp;quot;curve&amp;quot; whenever I make a recording.&lt;br /&gt;&lt;br /&gt;E: See here for the mentioned comment: &lt;a href="https://github.com/edgeimpulse/firmware-nordic-thingy53/blob/main/src/sensors/ei_microphone.cpp#L314-L331"&gt;https://github.com/edgeimpulse/firmware-nordic-thingy53/blob/main/src/sensors/ei_microphone.cpp#L314-L331&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Also here a screenshot of the attached audio data visualized to maybe give you better context. In this case little bit of the first sample got missed in my log, usually the click occurs after the first sample, here it looks like it starts shortly within the first sample. The spikes after are from the 2-4th sample. You can see the regularity of a click after exactly 100ms, which is how much sampling data fits into one block.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1704819869957v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/463323?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 10:47:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69c02dbe-f516-480a-afe1-9b701af9ae05</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;I will set aside some time tomorrow to test this on my end. I am relatively sure that the UART link is somehow part of the problem, since the DMIC code itself is very straight forward.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have a scope or logic analyzer available in order to check the UART activity?&amp;nbsp;&lt;br /&gt;The UART would have to run close to 100% of the time for the bandwidth to be sufficient, any gaps between transactions or slowdowns would cause issues.&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462990?ContentTypeID=1</link><pubDate>Fri, 05 Jan 2024 21:34:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79179c0f-cdf8-4de5-a0c8-630a2d34cb60</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;I had tested fewer samples before, even just doing a single block results in having at least one click. The only times I saw a click sometimes not appear was with increasing block size significantly but it was inconsistent with some blocks having it and some not.&lt;br /&gt;&lt;br /&gt;I dump the samples by connecting via USB to a PC and saving the serial output to a file/logging it and use the python script in the project zip file to turn it from ASCII into a binary file. That binary file I then open in Adobe Audition by doing a raw PCM import. Audacity would probably also work.&lt;br /&gt;For the serial logging I use &amp;quot;tio&amp;quot; on an Ubuntu machine but any serial terminal should do it including the VSCode one that Nordic ships.&lt;br /&gt;&lt;br /&gt;Thanks for the link, I will see if there is anything significantly different that I can try.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462886?ContentTypeID=1</link><pubDate>Fri, 05 Jan 2024 12:49:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e7ad9ea-4bb3-4214-9493-51c970df0f01</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
[quote user="DiodesDelight"]the UART is set close to 1M Baud, that should be more than enough in theoery.[/quote]
&lt;p&gt;Hm, I would say it is just about enough.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;16000 samples/sec * 5 ascii characters pr sample * 10 bits pr character (including stop and start bit) = 800kBaud&lt;/p&gt;
&lt;p&gt;So it is enough, yes, but not by a large factor. The question is how much overhead there is in the driver, and how much CPU time is required to process all those samples and convert them to a string, before passing them to the UART driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would suggest running a&amp;nbsp;quick test just changing &lt;em&gt;num_samples&lt;/em&gt; in the loop to a small number like 10 and see if it makes a difference.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A colleague of mine recently did some work integrating a PDM mic on the nRF52832, and the code looks very similar:&lt;br /&gt;&lt;a href="https://github.com/Noy0908/smart_remote/blob/desktop_remote/src/smart_remote/drv_mic.c#L191-L218"&gt;https://github.com/Noy0908/smart_remote/blob/desktop_remote/src/smart_remote/drv_mic.c#L191-L218&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;By the way, how do you transfer the audio data to the PC for analysis?&amp;nbsp;&lt;br /&gt;If you still can&amp;#39;t make it work I will try to replicate your test here, but I need to figure out the easiest way of transferring the audio data somewhere else for playback. Maybe storing to SD card on the audio DK is the best bet...&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462719?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 14:12:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0602372f-bec7-4819-8d33-deec96271b6a</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Hi Torbj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;the UART is set close to 1M Baud, that should be more than enough in theoery.&lt;/p&gt;
&lt;p&gt;The pop occurs even at lower baud rates without a noticable change and given the dmic reads via DMA I don&amp;#39;t think that could cause a hickup? If its due to being too slow to free the memory blocks then I should get 4 click free blocks before seeing clicks but this is not the case.&lt;/p&gt;
&lt;p&gt;I only have the UART to check the validity of the samples. Printk via logging is disabled so the logging infrastructure should not interfere or be an overhead.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462645?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 10:15:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31882d2a-5d6d-4c5e-a7dc-ac7f5e5c6f78</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;Thanks, now I could download all the files &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;My main concern looking at your code is the&amp;nbsp;fact that you are printing all the data to the console using printk(), this might introduce quite a lot of delay in the main loop. Could you try to comment&amp;nbsp;this out and see if the pops go away?&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462583?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 17:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69b95de9-f8a9-4c88-83a6-38af9778df6d</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Oh weird, I edited the post with a new upload. Can you try again?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/462506?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 13:26:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cc7298b-d636-4ea2-bae1-042a6dcc2b84</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;For some reason the dmic.zip attachment is not able to load (the other attachment works). Would you be able to attach&amp;nbsp;this file one more time?&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: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/461865?ContentTypeID=1</link><pubDate>Wed, 27 Dec 2023 17:39:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b6901ab-3faa-4401-862b-b68ff3faea59</guid><dc:creator>timonsku</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&amp;nbsp; totally understand!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DMIC pop / click sounds between each memory block</title><link>https://devzone.nordicsemi.com/thread/461797?ContentTypeID=1</link><pubDate>Wed, 27 Dec 2023 12:33:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7718e0f3-406b-46ec-b0e0-7459cb64be66</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Timon&lt;/p&gt;
&lt;p&gt;I ended up with this case also. Unfortunately we are severely understaffed during the Christmas period, and I will have to investigate further next week.&amp;nbsp;I apologize for the inconvenience.&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></channel></rss>