<?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 data during interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66293/pdm-data-during-interrupt</link><description>Hi, 
 I would like to use the PDM interface for my application in nrf52840. 
 I configured the driver, and started using the SDK&amp;#39;s API successfully. 
 Question 1: 
 During the event: (p_evt-&amp;gt;buffer_released), As part of development, I am exploring some</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Oct 2020 09:22:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66293/pdm-data-during-interrupt" /><item><title>RE: PDM data during interrupt</title><link>https://devzone.nordicsemi.com/thread/272461?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 09:22:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a473614a-52d8-4dac-bf55-d025772db85f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Is the offset supposed to be different in all the graphs, or is that a result of ? And what is the first graph? Is it supposed to be a sinus wave as well?&lt;/p&gt;
&lt;p&gt;Just to be clear. The number 50-30000, is the number of samples, not buffers, right?&lt;/p&gt;
&lt;p&gt;And in the graph, the irregularities are only on the first 2-3 samples in that buffer. Is that correct?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How do you trigger each of these recordings? Do you stop sampling in between each sample set, or is it a continuous stream? E.g. in the 5000 samples graph. Has it been sampling continuously for 5000 samples, or did you sample 5000 samples, stopped and then started sampling and recording?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is there any way for me to reproduce this on a DK? Do you have a project folder that you can ship and send that will run on a DK? Please test the project in an unmodified SDK to make sure that you didn&amp;#39;t change anything outside the project folder before sending it.&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: PDM data during interrupt</title><link>https://devzone.nordicsemi.com/thread/272309?ContentTypeID=1</link><pubDate>Wed, 30 Sep 2020 12:35:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e473f76e-3e8b-43c7-bc73-eecd362cdbb7</guid><dc:creator>AlonBarak</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank for your reply.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In my code I disragard the first 50 samples samples.&lt;/p&gt;
&lt;p&gt;However, I still see a problem with the first&amp;nbsp;buffers -&amp;nbsp;big offsets in the sinus wave - whish is not centered around 0. It becomes stable only after ~10k buffers (64 X int16_t each).&lt;/p&gt;
&lt;p&gt;In attached picture, you can see the result as a function of how many&amp;nbsp;&lt;strong&gt;buffers&lt;/strong&gt; i allowed before recording.&lt;/p&gt;
&lt;p&gt;This is a problem for me since i am interested in single use, and get the data as fast as possible.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Alon&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/PDMs.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM data during interrupt</title><link>https://devzone.nordicsemi.com/thread/271369?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 14:02:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2ece604-1c7c-4059-9481-b1c8816cf14d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I have never really looked too deep into the PDM peripheral, and we don&amp;#39;t have an example, but I would guess that you have until the buffer is filled up the next time. I assume that it is double buffered, so that you can use one buffer freely while the other one is being filled. The time this takes depends on your sample rate and buffer size. You can of course try to start a timer, and check the tick count in these events (do this and nothing else) to see how frequently the interrupts occur. In that case, you should only copy the timestamp and set some flag in the interrupt. Let the main context check for the flag and print the timestamp, since the logging feature is relatively slow, compared to many of the peripherals.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="AlonBarak"]I plan to do no more than memcpy the buffer to a permanent place, but want to make sure the timing is OK.[/quote]
&lt;p&gt;&amp;nbsp;I understand. That sounds like a good plan.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="AlonBarak"]&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;The statement abofe relates to 50 samples and not buffers, correct?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;After these ~50 samples everything shoould be fine.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;P.S --&amp;gt; This means that if i use a 64 kB buffer i should discard the first result, correct?&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I agree. That is 50 samples, not buffers. If so you don&amp;#39;t necessarily need to discard the entire first buffer. Only the first ~50 samples in that buffer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I just remembered that we have a user that shared a PDM + fatfs project (&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/63545/pdm-simple-example"&gt;found here&lt;/a&gt;). Perhaps you can compare your PDM implementation with this one.&lt;/p&gt;
&lt;p&gt;&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: PDM data during interrupt</title><link>https://devzone.nordicsemi.com/thread/271353?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 13:22:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ddb85318-78cf-45b8-b803-b2d40982ce25</guid><dc:creator>AlonBarak</dc:creator><description>&lt;p&gt;About the first one, can you tell how long i am allowed to spend in the interrupt?&lt;/p&gt;
&lt;p&gt;I plan to do no more than memcpy the buffer to a permanent place, but want to make sure the timing is OK.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regarding the second one, I will check what you say.&lt;/p&gt;
&lt;p&gt;from the nrf data:&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The PDM acquisition can be started by the START task, after the SAMPLE.PTR and SAMPLE.MAXCNT registers have been written. When starting the module, it will take some time for the filters to start outputting valid data. Transients from the PDM microphone itself may also occur. The first few samples (typically around 50) might hence contain invalid values or transients. It is therefore advised to discard the first few samples after a PDM start.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The statement abofe relates to 50 samples and not buffers, correct?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After these ~50 samples everything shoould be fine.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;P.S --&amp;gt; This means that if i use a 64 kB buffer i should discard the first result, correct?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&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;Alon&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PDM data during interrupt</title><link>https://devzone.nordicsemi.com/thread/271348?ContentTypeID=1</link><pubDate>Thu, 24 Sep 2020 13:17:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50017b13-4636-4ac9-a422-079be9a4e067</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;The first one looks like you have spent too long in the interrupt, so that there possibly is an interrupt that was missed, so that there actually should be (at least) one sample buffer in between.&lt;/p&gt;
&lt;p&gt;I have not seen this before. Are you sure that the points from your graph are correct, and not some value left in RAM from something else?&lt;/p&gt;
&lt;p&gt;I noticed that all your samples start with the value right below 500. Is this a coincidence? Or is the first value not part of the sample?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>