<?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>CPU running from RAM halted during page erase</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67660/cpu-running-from-ram-halted-during-page-erase</link><description>Hi to community again! 
 
 I&amp;#39;m having trouble with TWIS during page erase on nRF52840 (FICR &amp;quot;Read 4 bytes @ address 0x10000104 (Data = 0x41414330)&amp;quot;) as the bus is stalled while waiting for IRQ handler to be called. Product specification says &amp;quot;The CPU</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Oct 2020 08:28:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67660/cpu-running-from-ram-halted-during-page-erase" /><item><title>RE: CPU running from RAM halted during page erase</title><link>https://devzone.nordicsemi.com/thread/277295?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 08:28:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8aa8dd1f-02ca-474c-b027-c5379c1c75c7</guid><dc:creator>pavel.kucera</dc:creator><description>&lt;p&gt;Thank you for the tip! Checking, that nvmc_page_erase is called from RAM was not enough, wait_for_flash_ready() was not inlined despite &amp;quot;inline&amp;quot; suggestion to compiler, after adding &amp;quot;__attribute__((always_inline))&amp;quot; it is really inlined and the IRQ is triggered, now I just have to check all dependencies of TWIS IRQ handler are really in RAM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CPU running from RAM halted during page erase</title><link>https://devzone.nordicsemi.com/thread/277165?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 14:04:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4706694-3dc6-473c-8e62-2ec244f60a90</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;With the help of a colleague we can see the same here, so it looks like there is still some hardware dependency that prevent this to work with interrupts even when running from RAM.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: My colleague may have made it work now, I am attaching an example that use timer to trigger a timer interrupt during the flash operation, it show in principle it should work. Hope the example can be of use.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/3364.sdk_5F00_17.0.2_5F00_peripheral_5F00_nvmc_5F00_cpu_5F00_halt3.zip"&gt;devzone.nordicsemi.com/.../3364.sdk_5F00_17.0.2_5F00_peripheral_5F00_nvmc_5F00_cpu_5F00_halt3.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Maybe your problem can be related to the flash wait is not inlined (ref wait_for_flash_ready()).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Alternative solution&lt;/strong&gt;:&amp;nbsp;The page erase can be done partially by using&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/nvmc.html#register.ERASEPAGEPARTIALCFG"&gt;ERASEPAGEPARTIALCFG&lt;/a&gt;, e.g. run&amp;nbsp;flash partial erase 9 times with a duration of 10ms = 90ms (which is more than the required 85ms). Then you can have application interrupts only delayed by 10ms during erase.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CPU running from RAM halted during page erase</title><link>https://devzone.nordicsemi.com/thread/277156?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 13:35:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d558f3bc-432a-47f5-a9a6-3b67954f90d8</guid><dc:creator>pavel.kucera</dc:creator><description>&lt;p&gt;NVMC-&amp;gt;ICACHECNF is 0 in this configuration. Targeted master is capable of clock stretching, but not for tens of ms, it will timeout way earlier. The setup from scope picture is not with targeted master. Will try to investigate if there is other interrupt left enabled from MBR that could touch flash and cause the stall here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: CPU running from RAM halted during page erase</title><link>https://devzone.nordicsemi.com/thread/277127?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 12:24:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e95831d8-3938-43da-88cb-32e458fbc900</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Interesting, I assume you have verified by debugger and possibly breakpoints that the code don&amp;#39;t &amp;quot;touch&amp;quot; the flash here when jumping to the vector table in ram. Could be interesting to see if the cache have any influence on this:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/nvmc.html#register.ICACHECNF"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/nvmc.html#register.ICACHECNF&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is a slight corner case, so not sure if this actually have been tested, so it may be that you need to avoid interrupts while running the code from RAM while nvmc is executing, for instance you&amp;nbsp;may need to handle the twis directly. Though typically it is allowed in twi to delay and stall bytes by clock stretching, this is something that the hardware will automatically do if the CPU don&amp;#39;t process or handle the data fast enough. Does the peer twi master device support clock stretching?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>