<?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>LPC MicrocontrollersのトピックRe: LPC822 execution stops suddenly</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1401736#M47684</link>
    <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I'm using LPC822 on my 2nd project and I remarked that suddenly the code execution of the MCU stops. It's not predictable but I often find the MCU stopped and an external reset is needed to restart the program execution.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;While we can see even less than you, who is supposedly in front of the board, there are some common causes for runtime errors.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In most cases, it is either a stack overflow or an illegal address (no memory or not enable peripheral).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My first recommendation is, try to debug it. When ending up in the hardfault handler (most likely), check the call stack.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If that doesn't help, you can instrument your code, i.e. add log outputs you watch at runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Determining the required stacksize for a project is mostly guesswork, and many toolchains just set an arbitrary default value and leave the rest entirely to the user. Without change, they invariably hardfault at the first try.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jan 2022 13:05:56 GMT</pubDate>
    <dc:creator>frank_m</dc:creator>
    <dc:date>2022-01-19T13:05:56Z</dc:date>
    <item>
      <title>LPC822 execution stops suddenly</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1401605#M47680</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using LPC822 on my 2nd project and I remarked that suddenly the code execution of the MCU stops. It's not predictable but I often find the MCU stopped and an external reset is needed to restart the program execution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To remedy to this problem I call NVIC_SystemReset(); after the main loop but it doesn't resolve the problem.&lt;/P&gt;&lt;P&gt;I joined a screenshot of my code that executes a simple i2c code read and the logging of i2c communication externally that indicates the program stuck. Even RTT viewer doesn't receive any new print data.&lt;/P&gt;&lt;P&gt;Will you have any idea or prevention to apply in order to avoid this type of execution stuck?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 09:43:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1401605#M47680</guid>
      <dc:creator>Elmar</dc:creator>
      <dc:date>2022-01-19T09:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: LPC822 execution stops suddenly</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1401736#M47684</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I'm using LPC822 on my 2nd project and I remarked that suddenly the code execution of the MCU stops. It's not predictable but I often find the MCU stopped and an external reset is needed to restart the program execution.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;While we can see even less than you, who is supposedly in front of the board, there are some common causes for runtime errors.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In most cases, it is either a stack overflow or an illegal address (no memory or not enable peripheral).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My first recommendation is, try to debug it. When ending up in the hardfault handler (most likely), check the call stack.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If that doesn't help, you can instrument your code, i.e. add log outputs you watch at runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Determining the required stacksize for a project is mostly guesswork, and many toolchains just set an arbitrary default value and leave the rest entirely to the user. Without change, they invariably hardfault at the first try.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 13:05:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1401736#M47684</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-01-19T13:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: LPC822 execution stops suddenly</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402359#M47693</link>
      <description>&lt;P&gt;What do you expect this to do (specifically, when do you expect the while(1) loop to end) ?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;While (1) 
{
xxxxx
xxxxx
}

NVIC_SystemReset();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As Frank said, you need to debug. There is no way any can help you with the (lack of) information you have given.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 07:11:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402359#M47693</guid>
      <dc:creator>carstengroen</dc:creator>
      <dc:date>2022-01-20T07:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: LPC822 execution stops suddenly</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402564#M47698</link>
      <description>&lt;P&gt;Thanks for your replies.&lt;/P&gt;&lt;P&gt;Here is the solution that I applied to restart the program and keep running :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/**
* @brief	Get stack pointer address
**/
static __inline__ void *sp_get(void)
{
	void *sp;
	__asm__ __volatile__ ("mrs %0, msp" : "=r"(sp));
	return( sp );
}
	
/* Initialize the stack check */
uint32_t initialSPValue = (uint32_t)(sp_get());
	
    while (1)
    {
		
		if (initialSPValue != (uint32_t)(sp_get()))
		{
			/* Cause software reset on stack sanity check error */
			NVIC_SystemReset();
			for(;;)
			{
				; /* Nothing to do here */
			}
		}

...
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Is there any way to read the variables of scatter file such as Stack_size, ram_addr, etc from the c source code?&lt;/P&gt;&lt;P&gt;Thanks in advance for your feedback.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 10:22:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402564#M47698</guid>
      <dc:creator>Elmar</dc:creator>
      <dc:date>2022-01-20T10:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: LPC822 execution stops suddenly</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402608#M47699</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Is there any way to read the variables of scatter file such as Stack_size, ram_addr, etc from the c source code?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No, because this is exactly what you &lt;EM&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/EM&gt; want. Having such system-dependant settings in the code is the opposite of portability.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;These are linker settings. Usually, they are accessible by the project properties.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; Here is the solution that I applied to restart the program and keep running :&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Not a good idea either.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Check where the error happens, and fix the bug. Your method is a customer annoyance - I would not be allowed to take such shortcuts for my projects.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Check out this document :&amp;nbsp;&lt;A href="https://www.keil.com/appnotes/files/apnt209.pdf" target="_blank"&gt;https://www.keil.com/appnotes/files/apnt209.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I still think increasing the stacksize can fix your issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have a Crossworks licence for private projects of mine. This toolchain sets a 256 byte stacksize by default.&amp;nbsp;Any moderate complex code or semihosting output ends up in a hardfault hander with this setting.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 11:45:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC822-execution-stops-suddenly/m-p/1402608#M47699</guid>
      <dc:creator>frank_m</dc:creator>
      <dc:date>2022-01-20T11:45:58Z</dc:date>
    </item>
  </channel>
</rss>

