<?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 K22: Hard Fault (exception #3) after floating point instruction in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623530#M37359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do have a project based on ProcessorExpert where I now start with some calculation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MK22FX512VMC12&lt;/LI&gt;&lt;LI&gt;ProcessorExpert 10.4.0 b140319&lt;/LI&gt;&lt;LI&gt;winIDEA 9.12.157&lt;/LI&gt;&lt;LI&gt;GCC&amp;nbsp;arm-2013q3&lt;/LI&gt;&lt;LI&gt;No RTOS&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Up to&amp;nbsp;now everything worked fine so far. Now I'm trying to scale some measurement values and with the first math instruction I enter hardware fault exception (vector #3).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Sample1.png"&gt;&lt;IMG alt="Sample1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/18328iE9EE3720F3BB6D7F/image-size/large?v=v2&amp;amp;px=999" title="Sample1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess that I doing something wrong in software but I don't know what.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My settings may be wrong - but floating point settings seems to be OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Compiler:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;-c $(EDNAME) -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard 
-gdwarf-2&amp;nbsp; -Wall -ffast-math -fomit-frame-pointer 
-I$(IRFDIR)\Generated_Code -I$(IRFDIR)\Sources 
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\iofiles" 
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\pdd\inc" 
-D__GNU__ -D__PE__‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linker:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard 
-Wl,-T,$(INDPATH) -Wl,-Map,$(OUTPUTDIR)\kernel.map,
--gc-sections -o $(OUTPUTPATH)‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand why an instruction&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;vldr.32 s14,[r3]‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;causes the hardware fault excpetion. The CPU&amp;nbsp;has an FPU, so it should work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be great if anybody can&amp;nbsp;help me with that.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do I have to ENABLE the FPU? (If so where do I find it in PE?)&lt;/LI&gt;&lt;LI&gt;Is there an error in the command line of compiler or linker?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;very much&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Nov 2020 13:52:57 GMT</pubDate>
    <dc:creator>thomas_k1</dc:creator>
    <dc:date>2020-11-02T13:52:57Z</dc:date>
    <item>
      <title>K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623530#M37359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do have a project based on ProcessorExpert where I now start with some calculation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;MK22FX512VMC12&lt;/LI&gt;&lt;LI&gt;ProcessorExpert 10.4.0 b140319&lt;/LI&gt;&lt;LI&gt;winIDEA 9.12.157&lt;/LI&gt;&lt;LI&gt;GCC&amp;nbsp;arm-2013q3&lt;/LI&gt;&lt;LI&gt;No RTOS&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Up to&amp;nbsp;now everything worked fine so far. Now I'm trying to scale some measurement values and with the first math instruction I enter hardware fault exception (vector #3).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="Sample1.png"&gt;&lt;IMG alt="Sample1.png" src="https://community.nxp.com/t5/image/serverpage/image-id/18328iE9EE3720F3BB6D7F/image-size/large?v=v2&amp;amp;px=999" title="Sample1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess that I doing something wrong in software but I don't know what.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My settings may be wrong - but floating point settings seems to be OK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Compiler:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;-c $(EDNAME) -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard 
-gdwarf-2&amp;nbsp; -Wall -ffast-math -fomit-frame-pointer 
-I$(IRFDIR)\Generated_Code -I$(IRFDIR)\Sources 
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\iofiles" 
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\pdd\inc" 
-D__GNU__ -D__PE__‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linker:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard 
-Wl,-T,$(INDPATH) -Wl,-Map,$(OUTPUTDIR)\kernel.map,
--gc-sections -o $(OUTPUTPATH)‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand why an instruction&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;vldr.32 s14,[r3]‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;causes the hardware fault excpetion. The CPU&amp;nbsp;has an FPU, so it should work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be great if anybody can&amp;nbsp;help me with that.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Do I have to ENABLE the FPU? (If so where do I find it in PE?)&lt;/LI&gt;&lt;LI&gt;Is there an error in the command line of compiler or linker?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;very much&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:52:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623530#M37359</guid>
      <dc:creator>thomas_k1</dc:creator>
      <dc:date>2020-11-02T13:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623531#M37360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CPACR |= (0xf &amp;lt;&amp;lt; 20);&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // enable access to FPU&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Professional support for Kinetis: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Findex.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/index.html&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Remote desktop one-on-one coaching: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.utasker.com%2Fservices.html" rel="nofollow" target="_blank"&gt;http://www.utasker.com/services.html&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Getting started to expert videos: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fwww.youtube.com%2Fresults%3Fsearch_query%3Dutasker%2Bshorts" rel="nofollow" target="_blank"&gt;https://www.youtube.com/results?search_query=utasker+shorts&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Mar 2017 19:24:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623531#M37360</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-03-27T19:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623532#M37361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks a lot you for your&amp;nbsp;hint - it solved my problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If someone has the same problem and is&amp;nbsp;reading this thread and now searching for CPACR register: I neither find in in my headers nor is it documented in the Kinetis&amp;nbsp;K22 Sub-Family Reference Manual. Use "CPACR" to find other threads which provide an&amp;nbsp;assembler snippet to enable &amp;nbsp;FPU access&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again to Mark!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Mar 2017 07:29:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623532#M37361</guid>
      <dc:creator>thomas_k1</dc:creator>
      <dc:date>2017-03-28T07:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623533#M37362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The Cortex-M4 core is not described in the user's manual because it is a 'standard' part from ARM. That means that anything to do with the core is fully documented by ARM at their "ARM Information Center". For enabling floating point see &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Finfocenter.arm.com%2Fhelp%2Findex.jsp%3Ftopic%3D%2Fcom.arm.doc.ddi0439b%2FBEHBJHIG.html" rel="nofollow" target="_blank"&gt;http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439b/BEHBJHIG.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Since the register is memory mapped it doesn't need any special instructions to access it so I would avoid assembler code (to ensure portability). If your framework doesn't supply it just add&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#define CORTEX_M4_BLOCK&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; 0xe000e000&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;#define CPACR *(unsigned long *)(CORTEX_M4_BLOCK + 0xd88)&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; // Co-processor Access Control Register&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Mar 2017 12:12:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623533#M37362</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-03-28T12:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623534#M37363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FYI, the MK22FA header file I access calls that SCB_CPACR, as part of the whole System-Control-Block at 0xE000E000&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Mar 2017 15:39:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623534#M37363</guid>
      <dc:creator>egoodii</dc:creator>
      <dc:date>2017-03-28T15:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: K22: Hard Fault (exception #3) after floating point instruction</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623535#M37364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark, Earl,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now find the SCB_CPACR block and can use it to setup FPU in C. &lt;/P&gt;&lt;P&gt;As beginner with ARM it was a good lessen to learn about standard parts and ARM information center :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Mar 2017 07:56:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K22-Hard-Fault-exception-3-after-floating-point-instruction/m-p/623535#M37364</guid>
      <dc:creator>thomas_k1</dc:creator>
      <dc:date>2017-03-30T07:56:50Z</dc:date>
    </item>
  </channel>
</rss>

