<?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>Pause peripherals when hitting a breakpoint?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17298/pause-peripherals-when-hitting-a-breakpoint</link><description>Is there a way to pause all peripherals when hitting a breakpoint? In particular, I would like to freeze the RTCs when I hit a breakpoint. My app wakes up once a second, and I pause the code for too long, interrupt on RTC0 never fires when the counter</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Oct 2016 15:46:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17298/pause-peripherals-when-hitting-a-breakpoint" /><item><title>RE: Pause peripherals when hitting a breakpoint?</title><link>https://devzone.nordicsemi.com/thread/66481?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 15:46:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c532c7db-abf2-46d6-b1e2-8e38414b281c</guid><dc:creator>CurtisHx</dc:creator><description>&lt;p&gt;I&amp;#39;m using VisualGDB, but this gives me some ideas on how to about it.  Other micros give you the option of freezing or continuing to run peripherals when a breakpoint is hit.  That would be nice to have on future NRF5 micros.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pause peripherals when hitting a breakpoint?</title><link>https://devzone.nordicsemi.com/thread/66480?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 11:59:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df38d8d4-1dff-46e3-a670-846b37a93c54</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Yes you can do it, but it may be cumbersome, at least it was when I tried to do it in Keil uVision.&lt;/p&gt;
&lt;p&gt;You can stop the RTC by writing to the memory address corresponding to the stop task. For RTC0 this is 0x4000B004 (see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/rtc.html?cp=2_2_0_24_9#topic"&gt;here&lt;/a&gt;), so you stop RTC0 by writing a &amp;#39;1&amp;#39; to this address. The debugger lets you halt execution, resume execution and write to memory addresses. You can make uVision execute functions when a breakpoint is hit, see &lt;a href="http://www.keil.com/support/man/docs/uv4/uv4_debug_functions.htm"&gt;here&lt;/a&gt;. The debugger will not stop when you execute the function so you have to stop it manually in the function. You do this by setting the &lt;a href="http://www.keil.com/support/man/docs/uv4/uv4_db_exp_sysvariables.htm"&gt;system variable&lt;/a&gt; &lt;code&gt;_break_&lt;/code&gt; to non-zero. The execution will halt after the function is called. The stop function may look something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FUNC void stop_rtc0(void)
{
    _WBYTE(0x4000B004,1);   //stop RTC0
    _break_=1;              //halt debugger
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can also skip using a function and just type this in the command field (see &lt;a href="http://www.keil.com/support/man/docs/uv4/uv4_debug_commands.htm"&gt;here&lt;/a&gt; for more info about debug commands):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;E CHAR 0x4000B004=1, _break_=1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I assume you want to start RTC0 again when you resume code execution. As it seems that the halt command (&lt;code&gt;_break_=1&lt;/code&gt;) is executed after the other breakpoint commands, you will have to add a new breakpoint right after where you stopped. In this breakpoint, execute command for starting RTC0 again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;E CHAR 0x4000B000=1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is my experience when I tried it using uVision. If someone has a better way of doing it, please comment. If someone know how to do this in other IDEs, please add an answer.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Monitor mode debugging&lt;/strong&gt;&lt;br /&gt;
Your problem may also be solved by using Monitor mode debugging. This will allow interrupts with higher priority than the one you specify to run even you stop code execution in the debugger. See &lt;a href="https://devzone.nordicsemi.com/blogs/877/monitor-mode-debugging-revolutionize-the-way-you-d/"&gt;this&lt;/a&gt; great tutorial (blog) about Monitor Mode debugging.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pause peripherals when hitting a breakpoint?</title><link>https://devzone.nordicsemi.com/thread/66479?ContentTypeID=1</link><pubDate>Mon, 24 Oct 2016 20:37:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:214d10b3-d896-415e-a322-0b2212cdf7ea</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;Not that I know of.  If you are trying to find a bug, just check the variables/registers at the breakpoint, and keep moving your breakpoint farther along.  You might also explore watchpoints, you can break on a change to a particular memory location.  Finally, use assert() liberally.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>