<?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 Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450949#M26727</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using gdb? I use this little script to help me display ARM exceptions &lt;A href="https://gist.github.com/tralamazza/294e45475fce0b8e6c63" style="line-height: 1.5;" title="https://gist.github.com/tralamazza/294e45475fce0b8e6c63"&gt;ARMv7 exception helper&lt;/A&gt;&lt;SPAN style="line-height: 1.5;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Jul 2015 16:48:53 GMT</pubDate>
    <dc:creator>danieltralamazz</dc:creator>
    <dc:date>2015-07-02T16:48:53Z</dc:date>
    <item>
      <title>HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450944#M26722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing the following code to store value in array of time and data.I am getting 2 warnings.&lt;/P&gt;&lt;P&gt;main6.c(17): warning:&amp;nbsp; #550-D: variable "time" was set but never used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long time[50];&lt;/P&gt;&lt;P&gt;main6.c(18): warning:&amp;nbsp; #550-D: variable "data" was set but never used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long data[50];&lt;/P&gt;&lt;P&gt;Code:-&lt;/P&gt;&lt;P&gt;#include "MKL46Z4.h"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Device header&lt;/P&gt;&lt;P&gt;void InitLED(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM-&amp;gt;SCGC5=SIM_SCGC5_PORTD_MASK;// Enable clock to PORTD&lt;/P&gt;&lt;P&gt;&amp;nbsp; PORTD-&amp;gt;PCR[5]=256;// Set pin 5 of PORTD as GPIO&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTD-&amp;gt;PDDR=(1u&amp;lt;&amp;lt;5);// Set pin 5 of PORTD as OUTPUT&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void InitSYSTICK(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SysTick-&amp;gt;CTRL=0;//Disable the systick timer&lt;/P&gt;&lt;P&gt;&amp;nbsp; SysTick-&amp;gt;LOAD=0x00FFFFFF;//Reload it to its full value 24 bits&lt;/P&gt;&lt;P&gt;&amp;nbsp; SysTick-&amp;gt;VAL=0;//Write something in current register to reset it&lt;/P&gt;&lt;P&gt;&amp;nbsp; SysTick-&amp;gt;CTRL=0x00000005;//101&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;int main()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned long time[50];&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned long data[50];&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned long i=0,now=0,last=0,j=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitLED();&lt;/P&gt;&lt;P&gt;&amp;nbsp; InitSYSTICK();&lt;/P&gt;&lt;P&gt;&amp;nbsp; last=SysTick-&amp;gt;VAL;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTD-&amp;gt;PTOR=(1u&amp;lt;&amp;lt;5);//Toggle LED&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(i&amp;lt;50)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; now=SysTick-&amp;gt;VAL;&lt;/P&gt;&lt;P&gt;&amp;nbsp; time[i]=(last-now);&lt;/P&gt;&lt;P&gt;&amp;nbsp; data[i]=PTD-&amp;gt;PDOR;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last=now;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i++;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(j=0;j&amp;lt;=800000;j++)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {}&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;I dont know where i am going wrong.Please Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 14:27:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450944#M26722</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-07-02T14:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450945#M26723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The compiler is correct: you write to these variables, but you do not read from them/use them.&lt;/P&gt;&lt;P&gt;If you want to get rid of the warnings, you either simply add some reads of the data, or you might mark it as volatile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using GCC, then you could use this pragma in front of the function too:&lt;/P&gt;&lt;P&gt;#pragma GCC diagnostic ignored "-Wunused-but-set-variable"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope ths helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 15:08:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450945#M26723</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2015-07-02T15:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450946#M26724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rohan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks ok. Warning message says that variable is set to some value but not used :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; time[i]=(last-now);&amp;nbsp; // this sets variable time&lt;/P&gt;&lt;P&gt;&amp;nbsp; data[i]=PTD-&amp;gt;PDOR; // this sets variable data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but nobody reads a value stored in arrays data[] and time[]. This warning message is probably shown due to enabled -Wall compiler option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example this reads a values from arrays and warning should not be shown (with disabled code optimizations -O0) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;time[i]= (last-now) + (time[0]-time[0]);&lt;/P&gt;&lt;P&gt;data[i]= PTD-&amp;gt;PDOR + (data[0]-data[0]);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ondrej&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 15:23:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450946#M26724</guid>
      <dc:creator>ondrejlutera</dc:creator>
      <dc:date>2015-07-02T15:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450947#M26725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The led is not blinking.When I Debug it,it reaches till data[i]=PTD-&amp;gt;PDOR; and then goes into the HardFault_Handler.I dont know why is this happening?&lt;/P&gt;&lt;P&gt;Using volatile has led to 0 warnings but its not working.Please Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 16:06:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450947#M26725</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-07-02T16:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450948#M26726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;The led is not blinking.When I Debug it,it reaches till data[i]=PTD-&amp;gt;PDOR; and then goes into the HardFault_Handler.I dont know why is this happening?&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #51626f;"&gt;Using volatile has led to 0 warnings but its not working.Please Help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 16:09:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450948#M26726</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-07-02T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450949#M26727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using gdb? I use this little script to help me display ARM exceptions &lt;A href="https://gist.github.com/tralamazza/294e45475fce0b8e6c63" style="line-height: 1.5;" title="https://gist.github.com/tralamazza/294e45475fce0b8e6c63"&gt;ARMv7 exception helper&lt;/A&gt;&lt;SPAN style="line-height: 1.5;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 16:48:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450949#M26727</guid>
      <dc:creator>danieltralamazz</dc:creator>
      <dc:date>2015-07-02T16:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450950#M26728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not getting what u said?I am new to embedded.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 08:00:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450950#M26728</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-07-03T08:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450951#M26729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You said that while debugging your execution goes into the HardFault_Handler. Are you using GDB to debug?&lt;/P&gt;&lt;P&gt;Even if you are not, you can probably inspect your registers. I have a mini debug session example here &lt;A href="https://gist.github.com/tralamazza/70180c9bddf981a253e1" title="https://gist.github.com/tralamazza/70180c9bddf981a253e1"&gt;Kinetis K24 debug session&lt;/A&gt;​ that might help you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 12:52:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450951#M26729</guid>
      <dc:creator>danieltralamazz</dc:creator>
      <dc:date>2015-07-03T12:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: HardFault_Handler</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450952#M26730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have no idea what you are talking about.I think there is some problem when i try to read the PDOR register because it is at this point that the debugger CMSIS-DAP goes into HardFault_Handler.&lt;/P&gt;&lt;P&gt;This Line: &lt;/P&gt;&lt;P&gt;data[i]=PTD-&amp;gt;PDOR;&lt;/P&gt;&lt;P&gt;it is at this point that the debugger goes to HardFault_Handler.Please look into it whether i am reading it correctly or is there a problem somewhere else in the code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jul 2015 14:02:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/HardFault-Handler/m-p/450952#M26730</guid>
      <dc:creator>rohananand</dc:creator>
      <dc:date>2015-07-03T14:02:57Z</dc:date>
    </item>
  </channel>
</rss>

