<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Hardfault Handler in LPC55S69 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944452#M56754</link>
    <description>&lt;P&gt;to add to that: the stack size for each task in FreeRTOS is assigned as parameter in the xTaskCreate() API call.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2024 11:39:39 GMT</pubDate>
    <dc:creator>ErichStyger</dc:creator>
    <dc:date>2024-08-30T11:39:39Z</dc:date>
    <item>
      <title>Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1941554#M56723</link>
      <description>&lt;P&gt;Hello Team,&lt;/P&gt;&lt;P&gt;This is regarding a Hardfault issue in LPC55S69.&lt;/P&gt;&lt;P&gt;I have created a c++ project and implemented changes for my project. As part of it, I am making use of C++ STL library features.&lt;/P&gt;&lt;P&gt;Below is the code snippet,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;I have an enum defined with few CMD codes,
typedef enum
{
CMD_INVALID = 0x9999,
CMD_0 = 0x0000,
CMD_1 = 0x0001,
CMD_2 = 0x0002,
CMD_3 = 0x0003,
CMD_4 = 0x0004,
CMD_5 = 0x0005,
CMD_6 = 0x0006,
CMD_7 = 0x0007,
CMD_8 = 0x0008,
CMD_9 = 0x0009,
}CMD_CODES;

I have initialized the map container
std::map&amp;lt;std::string, CMD_CODES&amp;gt; Protocol::commands_map;

In an initialization routine, inserting the elements
commands_map.emplace( std::string( "CMD1" ), CMD_1);
commands_map.emplace( std::string( "CMD2" ), CMD_2 );
commands_map.emplace( std::string( "CMD3" ), CMD_3 );
commands_map.emplace( std::string( "CMD4" ), CMD_4 );
commands_map.emplace( std::string( "CMD5" ), CMD_5 );
commands_map.emplace( std::string( "CMD6" ), CMD_6 );
commands_map.emplace( std::string( "CMD7" ), CMD_7 );
commands_map.emplace( std::string( "CMD8" ), CMD_8 );
commands_map.emplace( std::string( "CMD9" ), CMD_9 );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this initialization, I will performing other tasks.&lt;/P&gt;&lt;P&gt;But I am getting a hardfault error, in the initialization routine while inserting the elements. I am wondering, what is going on here.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sushmasan_0-1724791519409.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/295635iFBB92F3BB15AE7CA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sushmasan_0-1724791519409.png" alt="sushmasan_0-1724791519409.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can someone please let me know, what the issue is?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;San&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 20:48:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1941554#M56723</guid>
      <dc:creator>sushmasan</dc:creator>
      <dc:date>2024-08-27T20:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1941962#M56725</link>
      <description>&lt;P&gt;Looks like a possible stack overflow to me. Try to reserve more space for your MSP and PSP stack.&lt;/P&gt;&lt;P&gt;Other than that: this is the hardfault handler I'm using:&lt;BR /&gt;&lt;A href="https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuHardFault.c" target="_blank"&gt;https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/src/McuHardFault.c&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 08:19:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1941962#M56725</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2024-08-28T08:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1942408#M56734</link>
      <description>&lt;P&gt;While debugging the code, what I noticed was the heap size increasing which is very close to 100%, that's when hardfault is triggered. When I checked the allocated stack and heap size it was 4KB, that was the reason for the failure. After configuring the heap size to 8KB, the code worked just fine. The heap size used was around 6.2KB.&lt;/P&gt;&lt;P&gt;As you mentioned try more space for MSP, PSP stack. How can I do that?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 15:26:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1942408#M56734</guid>
      <dc:creator>sushmasan</dc:creator>
      <dc:date>2024-08-28T15:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1943963#M56744</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/221349"&gt;@sushmasan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;To increase the stack sizes for the Main Stack Pointer (MSP) and the Process Stack Pointer (PSP) in an MCUXpresso project, you typically need to modify the linker script or relevant configuration settings in your project. Here’s how you can do that:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;1. Check the Heap Size Definition&lt;BR /&gt;If you need to modify the heap size as well, look for similar definitions for the heap:&lt;BR /&gt;__HeapBase = __end__;&lt;BR /&gt;__HeapLimit = __StackLimit;&lt;BR /&gt;The heap size is usually defined by the difference between __HeapBase and __HeapLimit. Adjust these definitions accordingly if needed.&lt;BR /&gt;2. Adjusting MSP and PSP Stack Sizes&lt;BR /&gt;The MSP is used by default and typically allocated from the top of the RAM. If you are using a Real-Time Operating System (RTOS) like FreeRTOS, the PSP is used for tasks, and its size is managed by the RTOS configuration. For bare-metal applications, MSP adjustments in the linker script are usually sufficient.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;For RTOS-based applications:&lt;BR /&gt;&lt;BR /&gt;• MSP Stack Size: Controlled by the linker script (as shown above).&lt;BR /&gt;• PSP Stack Size: Adjusted via the RTOS configuration, often defined in FreeRTOSConfig.h or a similar configuration file.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;BR&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;&lt;SPAN class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"&gt;Hang&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 03:00:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1943963#M56744</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2024-08-30T03:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944451#M56753</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/221349"&gt;@sushmasan&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;both heap and stack (MSP) size you can easily change in the linker settings in MCUXpresso IDE (no linker file modification needed). Here are the settings with the MPS stack marked:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErichStyger_0-1725017655568.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/296303iC279B41B2E6CBDDC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErichStyger_0-1725017655568.png" alt="ErichStyger_0-1725017655568.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As for PSP (process stack pointer): this is used for the stacks of threads. Settings is depending on the RTOS used, for example for FreeRTOS it is a configuration define:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#define configTOTAL_HEAP_SIZE                       (32*1024)&lt;/LI-CODE&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 11:35:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944451#M56753</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2024-08-30T11:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944452#M56754</link>
      <description>&lt;P&gt;to add to that: the stack size for each task in FreeRTOS is assigned as parameter in the xTaskCreate() API call.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 11:39:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944452#M56754</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2024-08-30T11:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hardfault Handler in LPC55S69</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944531#M56755</link>
      <description>&lt;P&gt;Thanks for explanation&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/229957"&gt;@Harry_Zhang&lt;/a&gt;, it is very helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2024 14:24:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Hardfault-Handler-in-LPC55S69/m-p/1944531#M56755</guid>
      <dc:creator>sushmasan</dc:creator>
      <dc:date>2024-08-30T14:24:20Z</dc:date>
    </item>
  </channel>
</rss>

