<?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>nRF52840: 0.4 mA extra sleep current after QSPI writes from RAM8, depending on code alignment</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/129563/nrf52840-0-4-ma-extra-sleep-current-after-qspi-writes-from-ram8-depending-on-code-alignment</link><description>nrf52840, Zephyr, ncs 3.4.1 
 
 For a few months I have been tracking an intermittent issue with a product that is close to production release. 
 
 The symptom of this problem is an excess 0.4 mA current during sleep. The excess current was observed to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 05 Nov 2026 18:20:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/129563/nrf52840-0-4-ma-extra-sleep-current-after-qspi-writes-from-ram8-depending-on-code-alignment" /><item><title>RE: nRF52840: 0.4 mA extra sleep current after QSPI writes from RAM8, depending on code alignment</title><link>https://devzone.nordicsemi.com/thread/572921?ContentTypeID=1</link><pubDate>Thu, 05 Nov 2026 18:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:718ff835-70aa-419d-94fc-f5657171fc54</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Interesting problem, and a very good description. There is an issue with sharing an AHB Slave between a peripheral DMA and the CPU stack or other peripheral DMA, which may possibly be related as (as far as I know) the QSPI may not handle bus stalls well in relation to hardware clock handling, unlike the nRF54L15. Any stack access (interrupts or CPU) or other higher-priority peripheral DMA access will take precedence over QSPI DMA access via the same AHB bus causing a bus stall which may not handle SCK well.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;If two (or more) bus masters request access to the same slave device, the master with the highest&lt;/em&gt;&lt;br /&gt;&lt;em&gt;priority is granted the access first.&amp;nbsp;Bus masters with lower priority are stalled until the higher priority master has completed its transaction.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There is a two stage AMLI (AHB Multi-Layer Interface)&amp;nbsp;bus system in the nRF52840 and nRF52833 instead of one stage on the nRF52832 and this makes avoiding the stall on the nRF52840 more difficult to design around. The simple fix - assuming this is an issue in this case - is to separate QSPI AHB RAM from all other RAM which might be accessed during a transaction. Place the stack in any other RAM area, say RAM7; this would imply that placing both stack and QSPI DMA in (say) RAM7 would give an identical problem, but without knowing which other transactions can take place over shared RAM8 or shared RAM7 (whichever is chosen) that&amp;#39;s hard to predict. I did some investigation on this issue when trying to precisely align multiple PWM outputs which was more difficult on the nRF52833 vs nRF52832.&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/108184/start-pwms-synchronous"&gt;start-pwms-synchronous&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The reduced code version mentions that the workaround for Errata 122 has been implemented, but supposedly two writes are required&amp;nbsp; in the workaround (010 and 054) whereas the notes on github only mention one&amp;nbsp; (054):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;*(volatile uint32_t *)0x40029010ul = 1ul;
*(volatile uint32_t *)0x40029054ul = 1ul;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;010 is TASKS_DEACTIVATE, so is this an errata documentation bug or not? I ask as the errata states the workaround should be implemented before deactivating- &amp;quot;&lt;em&gt;Execute the following code before disabling QSPI&lt;/em&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;Regarding the nops, clearly adding nops allow displacing code memory locations, and perhaps less obviously adding nops also displaces time of code-triggered events such as the start of a QSPI transfer. The 8-28-8 byte DMA bursts may happen to occur near another interrupt event such as a hardware timer (zephyr) such that a DMA access may or may not collide with a timing interrupt stack register push thus causing (or not) a bus stall. 64MHz code execution vs 16MHz peripheral DMA allows fine tuning of such an event. Separating stack and DMA AHB busses fixes that issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840: 0.4 mA extra sleep current after QSPI writes from RAM8, depending on code alignment</title><link>https://devzone.nordicsemi.com/thread/572915?ContentTypeID=1</link><pubDate>Thu, 05 Nov 2026 15:00:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9da48518-1c53-4c01-ac8a-55dc90fc2cc1</guid><dc:creator>tdickenson</dc:creator><description>&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;nrf52840, Zephyr, ncs 3.4.1&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;For a few months I have been tracking an intermittent issue with a product that is close to production release.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;The symptom of this problem is an excess 0.4 mA current during sleep. The excess current was observed to start after a burst of application activity (including QSPI flash writes), and continues until the next Bluetooth radio event.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;The current profile is flat. Mostly this problem does not occur. But on some builds it occurs nearly every sleep. Then making the smallest change to the firmware would cause the problem to vanish, making this&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;super-difficult to investigate.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;With Claude&amp;#39;s help I have been able to identify the circumstances where it occurs, and build a minimal example that runs on the development kit board.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;The circumstances are:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; It requires a certain pattern of QSPI flash writes. The minimal example uses a pattern of three writes that is common to our application. The issue does not occur after a single flash write.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; The source of the flash write needs to be in RAM8 (RAM above 0x20010000). The issue does not occur if the writes are from a lower RAM address (RAM0 to RAM7).&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; The write needs to occur from a thread whose stack is in RAM8. The issue does not occur if the stack is at a lower address.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Code alignment is an issue too. Adding some non-executed NOP instructions to a function in &lt;/span&gt;&lt;span style="color:rgba(128, 0, 0, 1);"&gt;`main.c`&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; shifts the rest of the application linked after it. Shifting by 2 to 6 bytes affects whether the issue occurs. I have not investigated exactly which instruction is sensitive.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;The excess current will last indefinitely, but it seems to be ended by another EasyDMA transfer. We have tried two:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; In the product it ends at the next radio event. In the example built with a Bluetooth beacon, on the DK, it ends at the next advertising event.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; In an earlier version of the example, encrypting one AES block on the ECB, which reads and writes through EasyDMA, ends it at once, whether the ECB&amp;#39;s data was in RAM8 or below it.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;It is drawn by the nRF52840 itself. On the DK, the current measurement covers the nRF52840&amp;#39;s supply alone, without the QSPI flash: 400 &amp;micro;A at 3.0 V, against a 2 &amp;micro;A floor when the issue doesn&amp;#39;t occur. The results for each build are in the example&amp;#39;s README.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;What I have done:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Published a minimal example that reproduces the excess 0.4 mA on the development kit, and demonstrates the expected low sleep current with trivial program changes.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Reproduced it with nRF Connect SDK v3.4.1 exactly as released, every repository at its manifest revision with no local changes.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Confirmed the current difference is not due to any expected effect from the firmware. In the high-current state, read through the debugger: the QSPI peripheral is disabled with its pins in their sleep state, the flash is in deep power-down, and the peripheral enables, timers, PPI, GPIOTE, pin configuration and RAM power registers are the same as at the normal floor. It looks like this code is triggering some incorrect internal silicon state.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Confirmed this is not anomaly 122. That errata documentation is light on details, it looks similar, but nrfx already applies the documented workaround at every disable (&lt;/span&gt;&lt;span style="color:rgba(128, 0, 0, 1);"&gt;`nrf_qspi_disable()`&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; in &lt;/span&gt;&lt;span style="color:rgba(128, 0, 0, 1);"&gt;`hal/nrf_qspi.h`&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;. Doubling up this workaround (in various ways) has no effect on this issue.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Ruled out anomaly 276, which describes a similar 400 to 450 &amp;micro;A after the SAADC stops in scan mode: the example never enables the SAADC.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;The chip on our module reads build code D0 (FICR INFO.VARIANT = AAD0), which is Revision 2&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;What I have not done:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:rgba(4, 81, 165, 1);"&gt;*&lt;/span&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt; Confirmed that all of the code widgets written by Claude (for example the kconfig options to move stacks into different blocks of ram) have expected effect. But I have no specific reason to doubt.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;At this point I have a workaround which involves copying every QSPI flash write through a buffer at a controlled RAM address. This appears to eliminate all problems, in the example and in our product. This workaround has proven solid (so far) so there is no urgency from our side, but it would be good to understand what is going on here.&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;span style="color:rgba(59, 59, 59, 1);"&gt;Reproduction example is here: &lt;a href="https://github.com/tobydickenson/tailissue"&gt;github.com/.../tailissue&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840: 0.4 mA extra sleep current after QSPI writes from RAM8, depending on code alignment</title><link>https://devzone.nordicsemi.com/thread/572913?ContentTypeID=1</link><pubDate>Thu, 05 Nov 2026 14:24:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e1dc9ab-33b6-4591-8c7c-6ab1fae41045</guid><dc:creator>Pallavi Patil</dc:creator><description>&lt;p&gt;Hie&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I agree, I am not able to read your case since some of the sentences are ending abruptly.&amp;nbsp; Can you please create a new case with the same text. Can you paste the text in notepad/word and then copy the text to create the new ticket. It might help.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Pallavi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840: 0.4 mA extra sleep current after QSPI writes from RAM8, depending on code alignment</title><link>https://devzone.nordicsemi.com/thread/572903?ContentTypeID=1</link><pubDate>Thu, 05 Nov 2026 12:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3329748-94f5-4875-a3fe-cc468e8dcb9f</guid><dc:creator>tdickenson</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure what happened to the formatting above&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>