<?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>Stack violation: stack pointer outside stack area.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45490/stack-violation-stack-pointer-outside-stack-area</link><description>Hi, 
 i get hardfault for some reason. This is RTT output: 
 
 and this is the output of GDB: 
 
 and backtrace gives this: 
 
 is there a nice way to find out where the hardfault happend and what could cause it? 
 I am using nrf52840 and SDK 15.2 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Mar 2019 15:29:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45490/stack-violation-stack-pointer-outside-stack-area" /><item><title>RE: Stack violation: stack pointer outside stack area.</title><link>https://devzone.nordicsemi.com/thread/179010?ContentTypeID=1</link><pubDate>Thu, 28 Mar 2019 15:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e068da8e-b444-48c9-b899-638ddcf204b2</guid><dc:creator>Cyril</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;p_stack_address = 0 which might be due to the&amp;nbsp;&lt;span&gt;__StackTop and&amp;nbsp;&lt;/span&gt;&lt;span&gt;__StackLimit definitions.&lt;br /&gt;Take a look at hardfault_handler_gcc.c which calls&amp;nbsp;&lt;/span&gt;HardFault_c_handler. The parameter to&amp;nbsp;HardFault_c_handler is set to 0 if the SP is not located into the Stack limit.&amp;nbsp;&lt;br /&gt;I would advise setting&amp;nbsp;__STACK_SIZE in your Makefile (or increasing to the max possible value it if already defined) to &amp;quot;allocate&amp;quot; a larger size than the default one which is 2048.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Then, you&amp;#39;ll be able to get the PC where the hardfault occured in&amp;nbsp;HardFault_c_handler using ((&lt;span&gt;HardFault_stack_t &lt;/span&gt;*)p_stack_address)-&amp;gt;&lt;span&gt;pc.&lt;br /&gt;&lt;br /&gt;Good luck&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>