<?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: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065 in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562545#M16784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by frame on Fri Apr 12 06:07:03 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;3, I did not check the stack carefully. What I saw is that&amp;nbsp; "b.w 0x1e24"&amp;nbsp; is causing hardwarefault&lt;BR /&gt;This branch instruction will not consume any&amp;nbsp; more stack usage.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Well, I'm not much into assembler programming, but ARM lists a B.W instruction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[B]only[/B] for the M3, and not for the M0 (M0+).&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0432c/CHDCICDF.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While the offset seems to be in range, the op code might indeed be invalid for the M0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That would be a case for for the CodeRed support then.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But as a workaround, you can use a well scaled integer calculation instead...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, in case of a stack overflow, something else (like data) usually&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets interpreted as instruction, and thus causing hardfaults.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 00:56:14 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T00:56:14Z</dc:date>
    <item>
      <title>Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562537#M16776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Thu Apr 11 05:06:32 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Please check the log!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562537#M16776</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562538#M16777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Thu Apr 11 06:00:17 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Given that you said the error occurs in lib_small_printf_m0, you should be posting the build log for that...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562538#M16777</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562539#M16778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Thu Apr 11 19:59:51 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Please check the log for lib_small_printf_m0.a&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562539#M16778</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562540#M16779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by frame on Thu Apr 11 23:44:54 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;Please check the log for lib_small_printf_m0.a&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;As developer, you should be able to do this yourself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, this build log seems ok, as -[FONT=Courier New]mcpu=cortex-m0[/FONT] is present.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You just have to make sure that the result of this build is the actual library you link against.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You wouldn't be the first one to be fooled by different lib versions in different folders.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is still the possibility of a stack overflow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You should be able to check the stackpointer against the limit while single-stepping into&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and through the offending function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562540#M16779</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562541#M16780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Fri Apr 12 03:18:48 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It is below bold line caused this issue. This is inside the library.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not change anything of this ADC example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;void ADCBar(int32_t Channel, uint32_t Counts)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; uint32_t ValueBarLen = ((Counts * (MAX_BAR_LENGTH+1)) - (ADC_COUNT_MAX/2 - 1)) / ADC_COUNT_MAX;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; char ValueBarBuf[BAR_OUTPUT_LENGTH+1];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [B][I]double ValueVolts = Counts*SUPPLY_VOLTAGE/ADC_COUNT_MAX;[/I][/B]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562541#M16780</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562542#M16781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by frame on Fri Apr 12 03:38:09 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;double ValueVolts = Counts*SUPPLY_VOLTAGE/ADC_COUNT_MAX;&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Fine, but actually, that doesn't help much. The C code does not give new hints toward the reason.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The assembler instruction at the vicinity of the hardfault is interesting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]printf [/FONT]uses [B]huge [/B]amounts of stack, even [FONT=Courier New]small_printf[/FONT] consumes considerably.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you check the stack at this time ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What keeps you from starting up your debugger ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And, BTW, you don't need floating point (even [FONT=Courier New]double[/FONT]) at this point. This simple scaling&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;can as well be done in integer. Double calculations are a waste of performance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it will take about 10 .. 50 times as long as using integer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562542#M16781</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562543#M16782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Fri Apr 12 04:02:24 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't forget that Cortex-M0 and Cortex-M3 do not have floating point hardware and therefore all floating point operations have to be emulated in software. This is implemented in function calls that will use more stack space.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note also that Cortex-M4 has single-precision floating point hardware, so [B]float[/B] will execute in hardware, but [B]double[/B] will be emulated in software.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Emulating floating point in software is very much slower than doing it in hardware.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562543#M16782</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562544#M16783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Fri Apr 12 04:31:09 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: frame&lt;/STRONG&gt;&lt;BR /&gt;Fine, but actually, that doesn't help much. The C code does not give new hints toward the reason.&lt;BR /&gt; &lt;BR /&gt;The assembler instruction at the vicinity of the hardfault is interesting.&lt;BR /&gt;[FONT=Courier New]printf [/FONT]uses [B]huge [/B]amounts of stack, even [FONT=Courier New]small_printf[/FONT] consumes considerably.&lt;BR /&gt;Did you check the stack at this time ?&lt;BR /&gt;What keeps you from starting up your debugger ?&lt;BR /&gt; &lt;BR /&gt;And, BTW, you don't need floating point (even [FONT=Courier New]double[/FONT]) at this point. This simple scaling&lt;BR /&gt;can as well be done in integer. Double calculations are a waste of performance,&lt;BR /&gt;it will take about 10 .. 50 times as long as using integer.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1, Please check the attached picture. First one is just before brance to library.Second one is just before hardware fault happen. If that instruction gets executed, hardfault occurs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2, Before hardware fault, no printf ever gets exectued.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3, I did not check the stack carefully. What I saw is that&amp;nbsp; "b.w 0x1e24" is causing hardwarefault. This branch instruction will not consume any more stack usage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4, If I use ver4, everything is OK. But since ver5 has great update, I would like to switch to this new version. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5, I am using adc to measure a signal ranging from 0v to 1.8v. Althrough I can avoid using floating point library in my real project like by using integer, I still want to use floating point which is more straight forward. And performance is OK as I am measuring PWM signal which has several kHz.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6, In my real project, I had another hardware fault which is something like " blx 0xxxxxxxxx". This is disassembly code inside the debugger. But user manual of cortex m0 shows there is only "blx Rm" which means blx can only use register as destination address. This is also puzzling me a lot.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562544#M16783</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562545#M16784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by frame on Fri Apr 12 06:07:03 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;3, I did not check the stack carefully. What I saw is that&amp;nbsp; "b.w 0x1e24"&amp;nbsp; is causing hardwarefault&lt;BR /&gt;This branch instruction will not consume any&amp;nbsp; more stack usage.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Well, I'm not much into assembler programming, but ARM lists a B.W instruction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[B]only[/B] for the M3, and not for the M0 (M0+).&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0432c/CHDCICDF.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While the offset seems to be in range, the op code might indeed be invalid for the M0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That would be a case for for the CodeRed support then.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But as a workaround, you can use a well scaled integer calculation instead...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, in case of a stack overflow, something else (like data) usually&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gets interpreted as instruction, and thus causing hardfaults.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562545#M16784</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562546#M16785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Fri Apr 12 07:01:26 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I've just tried building NXP's LPC11xx adc example project, and can't see any obvious issues with it that could be causing your fault.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please can you post:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) The axf file that you are debugging&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) the map file created when you built that axf&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) If possible, the actual project - main application project and any associated library projects - that you are building...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/ImportExport&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562546#M16785</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562547#M16786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Fri Apr 12 20:16:03 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;I've just tried building NXP's LPC11xx adc example project, and can't see any obvious issues with it that could be causing your fault.&lt;BR /&gt; &lt;BR /&gt;Please can you post:&lt;BR /&gt; &lt;BR /&gt;1) The axf file that you are debugging&lt;BR /&gt; &lt;BR /&gt;2) the map file created when you built that axf&lt;BR /&gt; &lt;BR /&gt;3) If possible, the actual project - main application project and any associated library projects - that you are building...&lt;BR /&gt; &lt;BR /&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2F" rel="nofollow" target="_blank"&gt;http://support.code-red-tech.com/CodeRedWiki/ImportExport&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;Regards,&lt;BR /&gt;CodeRedSupport&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please check the attached zip file of this ADC example project. It contains the ADC and small_printf lib. In folder named " debug", you will find the axf and map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[B]Please be noted that this example is OK under ver4.3 but both ver5.0 and v5.1 have this problem.[/B]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As what I had said that I had another hardware fault which is caused by "blx 0x****h". The destination address is a function that I wrote in assembly code. I just declared it as an extern function in C file. Then the compiler would produce this "blx 0x****h". Unfortunately, m0 does not have this branch instruction. The core selected by compiler/linker is indeed m0. But aganin, ver4.3 does not have this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you can see, I have three version installed on my PC but each in different folder/driver. I don't think installing path will produce this issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had this issue for more than one month. Since then I had to work under ver4.3. But ver5.1 has some advance like it takes less time to build or lauch the debugger. That is why I would like to switch to ver5.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562547#M16786</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562548#M16787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Fri Apr 12 20:37:25 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: frame&lt;/STRONG&gt;&lt;BR /&gt;Well, I'm not much into assembler programming, but ARM lists a B.W instruction&lt;BR /&gt;[B]only[/B] for the M3, and not for the M0 (M0+).&lt;BR /&gt;&lt;A href="http://"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0432c/CHDCICDF.html&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;While the offset seems to be in range, the op code might indeed be invalid for the M0.&lt;BR /&gt;That would be a case for for the CodeRed support then.&lt;BR /&gt; &lt;BR /&gt;But as a workaround, you can use a well scaled integer calculation instead...&lt;BR /&gt; &lt;BR /&gt;BTW, in case of a stack overflow, something else (like data) usually&lt;BR /&gt;gets interpreted as instruction, and thus causing hardfaults.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, integer is of course an alternative.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And for the case you mentioned that the core try to interpret data as an instruction. Normally this happens when returning address inside the stack gets corrupted due to stack overfollow. Next after trying to return, PC would be replaced by some data value. PC might point to invalid address or&amp;nbsp; valid RAM space. Then it is possible to produce fault. In my case, what I saw is that PC is still inisde the flash space.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562548#M16787</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562549#M16788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Sat Apr 13 12:14:57 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: cakehuang&lt;/STRONG&gt;&lt;BR /&gt;Thanks for your response.&lt;BR /&gt;Please check the attached zip file of this ADC example project. It contains the ADC and small_printf lib. In folder named " debug", you will find the axf and map.&lt;BR /&gt;[B]Please be noted that this example is OK under ver4.3 but both ver5.0 and v5.1 have this problem.[/B]&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OK, I can see what is triggering your issue with this adc example. The example set this was taken from was produced by NXP some considerable time ago, and for some reason uses linker scripts that NXP produced, rather than the managed linker script mechanism that LPCXpresso projects would normally use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The linker script is failing to pad one of its sections out to a 4 byte alignment, and a block of constant data is being pulled in from the small_printf project that the adc example uses that is not a multiple of 4 bytes is size. This is then causing a hiccup with the programming of your image into flash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The flash programming issue does not occur with the a current internal build of the next LPCXpresso release (due later this month). But in the meantime, the attached linker script contains a small modification to ensure 4 byte alignment is preserved in your image - which should allow you to flash your image using LPCXpresso v5.1.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To use this, simple extract the file from the zip file and place it into the 'linker' folder within the adc project. Then do a clean, followed by a full build.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;As what I had said that I had another hardware fault which is caused by "blx 0x****h". The destination address is a function that I wrote in assembly code. I just declared it as an extern function in C file. Then the compiler would produce this "blx 0x****h". Unfortunately, m0 does not have this branch instruction. The core selected by compiler/linker is indeed m0. But aganin, ver4.3 does not have this problem.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would need to see a buildable example to confirm, but I suspect that you have not declared your assembler function as a 'thumb_func'. &lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fhttp%3A%2F%2Fknowledgebase.nxp.com%2Fshowthread.php%3Ft%3D2182" rel="nofollow" target="_blank"&gt;Search the forum&lt;/A&gt;&lt;SPAN&gt; for earlier threads containing assembler examples.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562549#M16788</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562550#M16789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Tue Apr 16 03:36:59 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It is working under vesion 5.1 after replacing the original linkscript file with the new one that you sent me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And please help to check my modified SSP example project to see what is causing the blx instruction. I searced in this forum for assembler example and found one. I tried to add ".thumb" in file of sspmasterread.s. But this does not help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In this test case, I use SPI master to read. I wrote a funtion called "MasterReceive" in that asm file. Then I declared that function in c file and then call it. What I saw is the compiler produce this function call as "blx 0x***". I double checked the build log and found both c compiler and assembler select right core as m0.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562550#M16789</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562551#M16790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Tue Apr 16 03:53:13 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: cakehuang&lt;/STRONG&gt;&lt;BR /&gt;It is working under vesion 5.1 after replacing the original linkscript file with the new one that you sent me.&lt;BR /&gt;Thank you so much for your help.&lt;BR /&gt;And please help to check my modified SSP example project to see what is causing the blx instruction. I searced in this forum for assembler example and found one. I tried to add ".thumb" in file of sspmasterread.s. But this does not help.&lt;BR /&gt;In this test case, I use SPI master to read. I wrote a funtion called "MasterReceive" in that asm file. Then I declared that function in c file and then call it. What I saw is the compiler produce this function call as "blx 0x***". I double checked the build log and found both c compiler and assembler select right core as m0.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry that I fogot to attach this testing projectl&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562551#M16790</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562552#M16791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by whitecoe on Tue Apr 16 04:13:32 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;As CodeRedSupport has already told you, there are lots of earlier examples here. &lt;/SPAN&gt;&lt;A href="http://http://knowledgebase.nxp.com/showthread.php?t=2182" rel="nofollow noopener noreferrer" target="_blank"&gt;Search&lt;/A&gt;&lt;SPAN&gt; for "thumb_func", or "assembler" or "asm". For example the below thread, and the ones it links to should help further...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://" rel="nofollow noopener noreferrer" target="_blank"&gt;http://knowledgebase.nxp.com/showthread.php?t=674&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway, what you need is something like...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .global MasterReceive
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .thumb
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .thumb_func
 MasterReceive:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PUSH&amp;nbsp;&amp;nbsp;&amp;nbsp; {r4,r5,r6,r7,lr}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, be aware that you really should be pushing pairs of registers to the stack to ensure that 8 byte alignment of the stack is preserved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562552#M16791</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Build log:ADC example project HardFault exeception in LPCXpresso v5.1.2_2065</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562553#M16792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cakehuang on Tue Apr 16 05:45:38 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: whitecoe&lt;/STRONG&gt;&lt;BR /&gt;As CodeRedSupport has already told you, there are lots of earlier examples here. &lt;A href="http://http://knowledgebase.nxp.com/showthread.php?t=2182" rel="nofollow noopener noreferrer" target="_blank"&gt;Search&lt;/A&gt; for "thumb_func", or "assembler" or "asm". For example the below thread, and the ones it links to should help further...&lt;BR /&gt; &lt;BR /&gt;&lt;A href="http://" rel="nofollow noopener noreferrer" target="_blank"&gt;http://knowledgebase.nxp.com/showthread.php?t=674&lt;/A&gt;&lt;BR /&gt; &lt;BR /&gt;Anyway, what you need is something like...&lt;BR /&gt; &lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .global MasterReceive
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .thumb
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .thumb_func
 MasterReceive:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PUSH&amp;nbsp;&amp;nbsp;&amp;nbsp; {r4,r5,r6,r7,lr}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt; &lt;BR /&gt;Also, be aware that you really should be pushing pairs of registers to the stack to ensure that 8 byte alignment of the stack is preserved.&lt;BR /&gt; &lt;BR /&gt;HTH!&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is working now under v5.1(v4.3 does not have this problem)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I also push one more register(r3) into stack to keep the stack boundary as 8 byte alignment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you all again for helping out.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:56:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Build-log-ADC-example-project-HardFault-exeception-in-LPCXpresso/m-p/562553#M16792</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T00:56:19Z</dc:date>
    </item>
  </channel>
</rss>

