<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/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/"><channel><title>Debug Hard fault -&amp;gt; LPC1317-64P</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31183/debug-hard-fault---lpc1317-64p</link><description> 
I want to debug hard fault in LPC1317-64P. 
I took reference from below site: 
 support.code-red-tech.com/.../DebugHardFault 

 
But code gives error 

 
1. for asm Code: 

 
source\main.c(12): warning: #1207-D: attribute &amp;quot;naked&amp;quot; ignored 
source\main</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Debug Hard fault -&gt; LPC1317-64P</title><link>https://community.arm.com/thread/61485?ContentTypeID=1</link><pubDate>Thu, 14 Mar 2013 00:10:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9ccbd4da-c7ec-47e5-8978-fdec564af88f</guid><dc:creator>????? ??????</dc:creator><description>&lt;p&gt;&lt;pre&gt;
#pragma pack(push, 4)
typedef struct
{
        uint32_t r0;
        uint32_t r1;
        uint32_t r2;
        uint32_t r3;
        uint32_t r12;
        uint32_t lr;
        uint32_t pc;
        uint32_t psr;
} stacked_regs_t;
#pragma pack(pop)

//=============================================================================
// This is called from the HardFault_HandlerAsm with a pointer the Fault stack as the parameter.
// We can then read the values from the stack and place them into local variables for ease of reading.
//=============================================================================
void hard_fault_debug_print(stacked_regs_t* stack) // prints 8 regs saved on the stack and so on
{
        dprintf(&amp;quot;\n\nHard fault:\n&amp;quot;);
        dprintf(&amp;quot;R0  : %#08lx\n&amp;quot;, stack-&amp;gt;r0);
        dprintf(&amp;quot;R1  : %#08lx\n&amp;quot;, stack-&amp;gt;r1);
        dprintf(&amp;quot;R2  : %#08lx\n&amp;quot;, stack-&amp;gt;r2);
        dprintf(&amp;quot;R3  : %#08lx\n&amp;quot;, stack-&amp;gt;r3);
        dprintf(&amp;quot;R12 : %#08lx\n&amp;quot;, stack-&amp;gt;r12);
        dprintf(&amp;quot;LR  : %#08lx\n&amp;quot;, stack-&amp;gt;lr);
        dprintf(&amp;quot;PC  : %#08lx\n&amp;quot;, stack-&amp;gt;pc);
        dprintf(&amp;quot;PSR : %#08lx\n&amp;quot;, stack-&amp;gt;psr);
        dprintf(&amp;quot;BFAR: %#08lx\n&amp;quot;, *((volatile uint32_t*)0xE000ED38));
        dprintf(&amp;quot;CFSR: %#08lx\n&amp;quot;, *((volatile uint32_t*)0xE000ED28));
        dprintf(&amp;quot;HFSR: %#08lx\n&amp;quot;, *((volatile uint32_t*)0xE000ED2C));
        dprintf(&amp;quot;DFSR: %#08lx\n&amp;quot;, *((volatile uint32_t*)0xE000ED30));
        dprintf(&amp;quot;AFSR: %#08lx\n&amp;quot;, *((volatile uint32_t*)0xE000ED3C));
}


//=============================================================================
// Alternative Hard Fault handler to help debug the reason for a fault.
// To use, edit the vector table to reference this function in the HardFault vector
// This code is suitable for Cortex-M3 and Cortex-M0 cores
//=============================================================================

__irq __asm void HardFault_Handler(void) // __attribute__((naked))
{
        EXPORT  HardFault_Handler

        IMPORT  hard_fault_debug_print

        tst   lr, #(1&amp;lt;&amp;lt;2)
        ite   eq
        mrseq r0, msp                  ; Main Stack was used, put MSP in R0
        mrsne r0, psp                  ; Process Stack was used, put PSP in R0   and after: LDR R0,[R0, #24]   ; Get stacked PC from stack
        b     (hard_fault_debug_print)
        b     .
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>