<?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>Reliability of counting via interrupts on nrf52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93010/reliability-of-counting-via-interrupts-on-nrf52</link><description>Hello All, 
 Hoping to hear your opinion as I have little experience on how reliably the following would work. 
 The device should count pulses or edges from a reed switch in a reliable way and provide those values via BLE. Now apart from the obvious</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 20 Oct 2022 12:36:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93010/reliability-of-counting-via-interrupts-on-nrf52" /><item><title>RE: Reliability of counting via interrupts on nrf52</title><link>https://devzone.nordicsemi.com/thread/391665?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 12:36:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cdf4932-23d0-4a0a-bd78-9e40a684a912</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Barney,&lt;/p&gt;
&lt;p&gt;If you are looking at signals that are that slow, I would definitely go with the app_button module, as it has a SW debounce that you can set as long (or short) as you like. The drawback is that it requires the LFXTAL to run, but it will probably be running either way if you intend to do BLE stuff in your application. I forgot to ask if you are using the nRF5 SDK or NCS. The app_button is from the nRF5 SDK, but there are similar things in NCS.&lt;/p&gt;
&lt;p&gt;if you want to use the PPI approach, you will need external HW for debouncing.&lt;/p&gt;
&lt;p&gt;As for priorities and collisions. If the minimum ON-time is 100ms, that is plenty of time in case it would collide with the Softdevice. It will simply trigger the interrupt when the softdevice is done. This would only be an issue if you would receive two interrupts within one softdevice operation, in which case you would only receive one callback.&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><item><title>RE: Reliability of counting via interrupts on nrf52</title><link>https://devzone.nordicsemi.com/thread/391606?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 10:18:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9125673c-62c0-444e-9ba9-6a7f8ef914f1</guid><dc:creator>BarneyH</dc:creator><description>&lt;p&gt;Dear Daniel and Edvin,&lt;br /&gt;&lt;br /&gt;Thank you very much for your hints.&lt;br /&gt;I am expecting signals slower than 1 Hz and a minimum 100 ms ON-time. For debouncing I am thinking of a combined debounce/esd-protection chip, MAX16054 was the first hit that might work.&lt;br /&gt;For the interrupt latency I found less than 4 microseconds with SoftDevice (which I will use) on another thread, I guess this is worst-case.&lt;br /&gt;&lt;br /&gt;The app_button library seems fine for that use case, energy-wise this is probably the more efficient than PPI+timer?&lt;br /&gt;&lt;br /&gt;Kind regards,&lt;br /&gt;Barney&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reliability of counting via interrupts on nrf52</title><link>https://devzone.nordicsemi.com/thread/391588?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 09:00:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e0f2421-f34a-4ec3-b887-b83e9bc34e63</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Barney,&lt;/p&gt;
&lt;p&gt;At first, I thought about using PPI + a timer in counter mode for this. If you search for &amp;quot;PPI timer counter&amp;quot; here on DevZone you should see a bunch of tickets discussing the implementation of this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, it depends on the frequency of what you are trying to measure. If you need a debounce, the PPI approach will not work that good. Perhaps you want to look into the app_button library if you need a software debounce. If you have time for a debounce, then I think the app_button is probably sufficient.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So what is the frequency of&amp;nbsp;the signal&amp;nbsp;you are trying to measure? Are we talking 10Hz or 1MHz?&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><item><title>RE: Reliability of counting via interrupts on nrf52</title><link>https://devzone.nordicsemi.com/thread/391448?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 13:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e38df048-f5b0-483e-b687-9c7bf5172879</guid><dc:creator>Daniel Chisholm</dc:creator><description>&lt;p&gt;Presumably you will first debounce this in hardware?&lt;/p&gt;
&lt;p&gt;Once that is done, what is the shortest possible time between legitimate debounced edges that you will need to count? Once you have that number you can compare it to worst-case interrupt latency you will get when running BLE (you didn&amp;#39;t mention if you are using the softdevice on the nrf5 sdk, or if you are using ncs, etc). If interrupt latency is less than your shortest possible interval between signals, then interrupts should count every edge and miss none, without any additional hardware beyond the hardware debouncing.&lt;/p&gt;
&lt;p&gt;If interrupt latency is too slow then you need hardware help.&amp;nbsp; If you have an available TIMER peripheral, you can have it operate in counter mode, and therefore have a correct count with no missed edges.&amp;nbsp; Or, you can build off chip hardware (counter chip, or shift register, etc) to accomplish the same task (count edges for the interrupt service routine even when it&amp;#39;s latency is such that it is being called after more than one edge has fired)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>