<?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>Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40499/hardware-timer-interrupt-delayed-significantly-by-softdevice-or-even-missed</link><description>Hello, 
 I am having an issue where it appears that my hardware timer interrupts can occasionally be delayed by upwards of 20 ms or even be missed entirely. My code is based on Martin BL&amp;#39;s example as seen below. 
 Original thread: https://devzone.nordicsemi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 26 Jun 2019 20:29:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40499/hardware-timer-interrupt-delayed-significantly-by-softdevice-or-even-missed" /><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/194964?ContentTypeID=1</link><pubDate>Wed, 26 Jun 2019 20:29:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e962c56e-608f-4bd7-b674-8757f318d71b</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;Take a look at&amp;nbsp;my response to &lt;strong&gt;vittopascu&lt;/strong&gt; in this ticket for how this was (mostly) resolved:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/37731/nrf52840-spi-easydma-double-buffering"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/37731/nrf52840-spi-easydma-double-buffering&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It ended up not being a timer issue, but rather an issue with reading and updating TX.PTR. In short, you cannot update the TX.PTR while a SPI transaction is in progress despite what the datasheet says.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/194732?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 21:39:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3797fbc2-f6cf-494c-b926-8ccc2fe63e99</guid><dc:creator>kdubovenko</dc:creator><description>&lt;p&gt;Hello, I am running into the exact same bug with my NRF52840. I am using code based on &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/19891/transfer-more-than-255-bytes-with-spi-master-on-nrf52/144775#144775" rel="noopener noreferrer" target="_blank"&gt;this&lt;/a&gt; thread to read and write from SPI NAND via DMA using timer counter (timer2 in my case). I have tried it with SPIM 0-3 and all of them run into this issue. if BLE is off I can read/write 10s of thousands of files without an issue. When the BLE goes on, the device will miss an interrupt within the first 100 files, somewhat randomly. Was this issue ever resolved with &lt;a href="https://devzone.nordicsemi.com/members/droberson"&gt;droberson&lt;/a&gt;? I am happy to create a private case for this but figured others might experience this as well, have tired all sorts of ways to fix this to no avail.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/159178?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 09:17:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce0876e6-8ebc-4e74-9be9-dc1b28ff6c76</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;I saw your other case. I think it is best that we proceed over there.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/159116?ContentTypeID=1</link><pubDate>Mon, 26 Nov 2018 20:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4975123-7d5a-4d68-ba3e-b76f3fab9708</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;&lt;strong&gt;How often does it happen, and can you say something about the frequency of which it occurs?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;It appears to be random. It can happen within the first 10 minutes of it running or up to an hour later. It always occurs in less than 2 hours. I can perform the same operation when connected to my application via USB and I have absolutely no issue after 10 hours of continuous use, so it definitely seems related to the SoftDevice.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is this easy to reproduce?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Yes, just allow the application to run and wait an hour. It usually occurs within an hour.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Can you upload your code? We can make the case private if you prefer confidentiality.&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have actually created a private ticket per recommendation from my direct FAE contact that another engineer was assigned to. I will PM you the details.&lt;/p&gt;
&lt;p&gt;The code must remain confidential. I will continue my discussion in that thread in regards to how to upload my project.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/158836?ContentTypeID=1</link><pubDate>Fri, 23 Nov 2018 12:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dc88c02-4d87-4868-8445-d77b3e2c9c0b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;I have read on the forums that the TXD.PTR pointer is double buffered. Is there any rule as to when this should/can be updated?&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;Please refer to this&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/spim.html?cp=2_1_0_30_1#concept_svj_wt2_wr"&gt;documentation&lt;/a&gt;: &amp;quot;The .PTR and .MAXCNT registers are double-buffered. They can be updated and prepared for the next transmission immediately after having received the STARTED event.&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Is there a way to check if the SPIM peripheral is currently busy?&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;Unfortunately the only way is to control it in software&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;strong&gt;Is there a way to automatically reset the TX.PTR to the beginning of the ArrayList without CPU intervention? I ask this again because you were wandering why I implemented this mechanism.&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;No. I didn&amp;#39;t quite understand your reasoning at first, but I think I do now, and I think your strategy is good.&lt;/li&gt;
&lt;li&gt;Errata 198 shouldn&amp;#39;t be relevant unless you are using SPIM instance #3. Are you? If so, can you try with instance 0,1, or 2?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;How often does it happen, and can you say something about the frequency of which it occurs?&lt;/p&gt;
&lt;p&gt;Is this easy to reproduce?&lt;/p&gt;
&lt;p&gt;Would I be able to run your code and &lt;span&gt;reproduce&amp;nbsp;&lt;/span&gt;it on my desk?&lt;/p&gt;
&lt;p&gt;Can you upload your code? We can make the case private if you prefer confidentiality.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/157860?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 05:14:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cc0867f-c6d9-4ad0-b935-462c296fbaf4</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Martin,&lt;/p&gt;
&lt;p&gt;I did a bit more digging over the weekend and found something interesting. In my TIMER_COUNTER callback I added the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Reset the transmit buffer pointer offset to the start plus the number of bytes we went over
txPointerUpdated = ((uint32_t) buffer) + bufferOver;
spi3.p_reg-&amp;gt;TXD.PTR = txPointerUpdated;

// Make sure the TX pointer was actually updated
if(spi3.p_reg-&amp;gt;TXD.PTR != txPointerUpdated)
{
    cprintf(&amp;quot;TX.PTR should have been updated to 0x%x&amp;quot;, txPointerUpdated);
    cprintf(&amp;quot;TX.PTR is actually 0x%x&amp;quot;, spi3.p_reg-&amp;gt;TXD.PTR);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Sure enough, it appears that the TX.PTR is sometimes not getting updated as seen in the log below.&lt;/p&gt;
&lt;p&gt;(17:02:19.094) bufferOver 6&lt;br /&gt;(17:02:19.094) TXD.PTR = 0x2001782c and COUNTER CC0 = 1021&lt;br /&gt;(17:02:27.612) bufferOver 2&lt;br /&gt;(17:02:27.612) TXD.PTR = 0x20017826 and COUNTER CC0 = 1023&lt;br /&gt;(17:02:33.511) bufferOver 2&lt;br /&gt;(17:02:33.511) TXD.PTR = 0x20017826 and COUNTER CC0 = 1023&lt;br /&gt;&lt;strong&gt;(17:02:36.492) TX.PTR should have been updated to 0x20017822&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;(17:02:36.492) TX.PTR is actually 0x2001803a&lt;/strong&gt;&lt;br /&gt;(17:02:36.525) bufferOver 2046&lt;br /&gt;(17:02:36.525) TXD.PTR = 0x20018028 and COUNTER CC0 = 1&lt;/p&gt;
&lt;p&gt;Note that I increased the size of my buffer and overflow region to see if it made any difference before adding the TX pointer update check, which it didn&amp;#39;t of course. Hence why the numbers are larger than in my original post.&lt;/p&gt;
&lt;p&gt;A couple things:&lt;/p&gt;
&lt;p&gt;1. I have read on the forums that the TXD.PTR pointer is double buffered. Is there any rule as to when this should/can be updated? Is it possible that writing to the TXD.PTR while the DMA controller is reading it will cause it to not be updated since the DMA controller is also incrementing it?&lt;/p&gt;
&lt;p&gt;2. Is there a way to check if the SPIM peripheral is currently busy?&lt;/p&gt;
&lt;p&gt;3. Is there a way to automatically reset the TX.PTR to the beginning of the ArrayList without CPU intervention? I ask this again because you were wandering why I implemented this mechanism.&lt;/p&gt;
&lt;p&gt;I also took a look at the latest errata (&lt;a href="http://infocenter.nordicsemi.com/pdf/nRF52840_Rev_1_Errata_v1.1.pdf"&gt;http://infocenter.nordicsemi.com/pdf/nRF52840_Rev_1_Errata_v1.1.pdf&lt;/a&gt;) and the only one I see of interest is &amp;quot;3.30 [198] nRF52840: SPIM3 transmit data might be corrupted&amp;quot;. It talks about not accessing the data in the TX data buffer where TXD.PTR is pointing at the same time the DMA controller is fetching data. This is specific to the data itself, not the pointer to the data but I imagine the same restrictions apply.&lt;/p&gt;
&lt;p&gt;Any ideas, suggestions, or known workarounds for this?&lt;/p&gt;
&lt;p&gt;Thanks again for any help!&lt;/p&gt;
&lt;p&gt;Derek&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/157580?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 16:22:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:524350ed-bd6e-47ee-bb61-d27299fe6219</guid><dc:creator>droberson</dc:creator><description>&lt;p&gt;Hey Martin!&lt;/p&gt;
&lt;p&gt;My timer interrupts are set to priority 2 (Highest possible) for this reason. Normally, I am not printing any information to a debug UART during this time, but have added a few debug statements as highlighted in my original post in an attempt to debug why this is happening. Ie, it was happening prior to adding any debug statements.&lt;/p&gt;
&lt;p&gt;Based on the BLE peripheral timing diagram, I agree in that the SoftDevice shouldn&amp;#39;t block for more than a few hundred usec at a time, hence why I am stumped as to why this is happening.&lt;/p&gt;
&lt;p&gt;In regards to the buffer &amp;quot;mechanism&amp;quot; that I am using, the purposes of this is because the DAC writes need to occur indefinitely until the application tells it to stop. Given my understanding of ArrayLists, PPI, timers, and the SPI driver, the TXD.PTR must be reset by the CPU once all data&amp;nbsp;in the ArrayList&amp;nbsp;has been transmitted. In other words, the SPI driver cannot loop through the ArrayList without CPU intervention. This was confirmed by another FAE in my post here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/37731/nrf52840-spi-easydma-double-buffering"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/37731/nrf52840-spi-easydma-double-buffering&lt;/a&gt;&amp;nbsp;(Read the last 3 replies). If there is a way to indefinitely loop through an ArrayList without CPU intervention, that would be great! (As this is what I had hoped could be done originally). Or perhaps there is an easier way to achieve my desired behavior?&lt;/p&gt;
&lt;p&gt;I will look into the Errata list. I am using a Rigado branded nRF52840, so I need to figure out which revision Nordic chipset it is.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardware Timer interrupt delayed significantly by SoftDevice (Or even missed)</title><link>https://devzone.nordicsemi.com/thread/157561?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 14:57:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51ce097a-d6ee-49d5-b0fe-7eb61e91d34c</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=2_3_2_0_15_1"&gt;Higher priority interrupts will block lower priority interrupts&lt;/a&gt; and if you have an interrupt that runs for 20 ms or longer you will miss a timer interrupt (if it has lower priority). However, 20 ms is a relatively long time, so unless you are doing some serious processing or&amp;nbsp;printing a lot of data on a slow UART line&amp;nbsp;inside a high priority interrupt context&amp;nbsp;I find it difficult to believe that this is what happens.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The Softdevice alone should never block your application for 20 ms straight. You can see what latency to expect from the Softdevice &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.sds/dita/softdevices/s130/ble_processor_avail_interrupt_latency/ble_peripheral_connection_performance.html?cp=2_3_2_0_15_2_2_1"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But I don&amp;#39;t understand why you need this whole mechanism? With your 32 us timer and PPI you can transfer your buffer to the DAC autonomously. The Softdevice will never block your timer from starting the SPI.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you looked through the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52/dita/nrf52/errata52840.html?cp=2_0_1"&gt;Errata list&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Martin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>