<?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>How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12559/how-to-enable-etm-trace-in-nrf52-pca10040-board</link><description>Hi, 
 I am facing hardfault when i try to enable low power in a ble application. i want to enable trace on my PCA10040 board to find out the cause of this hardfault. can you help me to succeed to enable trace ? please. 
 Best regards.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 22 Apr 2016 13:29:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12559/how-to-enable-etm-trace-in-nrf52-pca10040-board" /><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47671?ContentTypeID=1</link><pubDate>Fri, 22 Apr 2016 13:29:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54a54666-e886-4349-8b3e-1c83545b486d</guid><dc:creator>Michael Dietz</dc:creator><description>&lt;p&gt;Blog post explaining how to do this step by step: &lt;a href="https://devzone.nordicsemi.com/blogs/909/debugging-nrf52-series-devices-using-trace/."&gt;devzone.nordicsemi.com/.../.&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47670?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 15:53:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:beb5b75b-fe47-429c-a0cb-30c5353d8b34</guid><dc:creator>Juba Belgaid</dc:creator><description>&lt;p&gt;Overview of my Ble application:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.
.
.
BleInit();
uart_init();
printf(&amp;quot;%s&amp;quot;,start_string);
DisplayInit();
NorFlashInit();
//scheduler init
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
		
//create Display timer
err_code = app_timer_create(&amp;amp;DisplayTimerId,	APP_TIMER_MODE_REPEATED,	DisplayEventHandler);
APP_ERROR_CHECK(err_code);
		
while (1)
{
	app_sched_execute();
	power_manage();

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;when proc is idle mode i measure a consumption current of~900uA, run mode ~6mA.
Hardfault occurs randomly (on connect event, display event ...etc) when it occurs i measure a consumption current of 10mA, and ble stops advertising.&lt;br /&gt;
To be sure that is a hardfault, i replaced&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HardFault_Handler\
                PROC
                EXPORT  HardFault_Handler         [WEAK]
                B       .
                ENDP
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;on arm_startup_nrf52.s by Reset_Handler code&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HardFault_Handler\
                PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  SystemInit
                IMPORT  __main
                
                LDR     R0, =SystemInit
                BLX     R0
                LDR     R0, =__main
                BX      R0
                ENDP
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then when the hardfault occurs, the board resets&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47669?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 15:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73cc66d3-1ba1-4da1-8fef-3a4c759396bc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Strange. how did you conclude it was a hardfault earlier? Halting the core with nrfjprog/jlink, or did you have a LED or similar in the event handler?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47668?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 15:40:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0c6ce66-c4ed-4299-aa55-f21e46a527cb</guid><dc:creator>Juba Belgaid</dc:creator><description>&lt;p&gt;i am unable to reproduce the hardfault with debug session !!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47667?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 12:46:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:909381da-ac67-41da-8e82-e192e7b1b117</guid><dc:creator>Juba Belgaid</dc:creator><description>&lt;p&gt;Thank you for your reply.
How can i display call stack?
I can&amp;#39;t insert breakpoints since the hardfault is random.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47666?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 11:42:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2bfeb0d-6004-4a31-b642-23e16ac86d8f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Unfortunately, the j-link plus does not appear to support trace. Does the call stack provide any clues as to what function caused the hardfault? I.e, are there any function calls on the stack prior to the hardfault? You can also get the PC value before the exception occurred by reading the memory at the current stackpointer pluss an offset of 24 bytes (SP+24).&lt;/p&gt;
&lt;p&gt;Also you can just insert breakpoints and determine how far the application gets before the exception occurs. With this you should be able to locate the code that triggers it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT - Attached screen dump for illustration&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The function call prior to the exception will generally be shown if it occurred in the application code. Also see that the address of the instruction that caused the hardfault is loaded to R0, but not sure if that is always the case.&lt;/p&gt;
&lt;p&gt;To illustrate this I triggered a hardfault exception by accessing an invalid memory area in the battery_level_update function found in the hrs example.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;dummy pointer to 0x8000000 which will cause hardfault when the cpu tries to fetch the content in the battery_level_update function.&lt;/li&gt;
&lt;li&gt;SP value pushed to stack prior to entering the event handler.&lt;/li&gt;
&lt;li&gt;problem function&lt;/li&gt;
&lt;li&gt;PC counter&lt;/li&gt;
&lt;li&gt;Same address to function call as shown in the memory view (4).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0624.hardfault.PNG" alt="image description" /&gt;&lt;/p&gt;
&lt;p&gt;You can download the image to enlarge it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47665?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 10:16:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccdca975-0897-4064-9282-877880373d06</guid><dc:creator>Juba Belgaid</dc:creator><description>&lt;p&gt;I have segger J-link Plus &lt;a href="https://www.segger.com/j-link-plus.html"&gt;www.segger.com/j-link-plus.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to enable ETM trace in nRF52 PCA10040 board</title><link>https://devzone.nordicsemi.com/thread/47664?ContentTypeID=1</link><pubDate>Tue, 15 Mar 2016 10:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:066a2e37-10ce-4edc-a24b-3afcf256424e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Do you have a J-link trace or similar? Note that the on-board J-link does not support trace.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>