<?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: Issue with setting CAN pins in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590960#M34784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brent,&lt;/P&gt;&lt;P&gt;As Charles responded, you need to clock peripherals first before using it, otherwise a hard fault will happen.&lt;/P&gt;&lt;P&gt;In case you need to find out what is causing the hard fault, the following might help you:&lt;/P&gt;&lt;P&gt;&lt;A href="https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/" title="https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/"&gt;https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Basically it means that you install a custom handler where you can get PC/cause of the fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the muxing: there is the NXP (Kinetis Expert) Pins tool which does the additional checks and as well turns on the clocks for you. See &lt;A href="https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/" title="https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/"&gt;https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/&lt;/A&gt;&amp;nbsp; and &lt;A href="https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/" title="https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/"&gt;https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jul 2016 06:44:43 GMT</pubDate>
    <dc:creator>BlackNight</dc:creator>
    <dc:date>2016-07-20T06:44:43Z</dc:date>
    <item>
      <title>Issue with setting CAN pins</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590958#M34782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: small;"&gt;Can someone explain why the "SetPinMux" function works correctly for PORTD but not PORTA. The attempt to SetPinMux for PORTA gives a hard fault. Also, what is a hard fault?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px; color: #222222; font-family: arial, sans-serif; font-size: small;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;void BOARD_InitPins(void)&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;{&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize UART1 pins below */&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Ungate the port clock */&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CLOCK_EnableClock(kCLOCK_PortD);&lt;/P&gt;&lt;P class="gmail_default" style="min-height: 8pt; padding: 0px; color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Affects PORTD_PCR8 register */&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_SetPinMux(PORTD, 8u, kPORT_MuxAlt3);&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Affects PORTD_PCR9 register */&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_SetPinMux(PORTD, 9u, kPORT_MuxAlt3);&lt;/P&gt;&lt;P class="gmail_default" style="min-height: 8pt; padding: 0px; color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*Set CAN0 */&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_SetPinMux(PORTA,12u,kPORT_MuxAlt2);&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PORT_SetPinMux(PORTA,13u,kPORT_MuxAlt2);&lt;/P&gt;&lt;P class="gmail_default" style="min-height: 8pt; padding: 0px; color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;}&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;P.S.&lt;/P&gt;&lt;P class="gmail_default" style="color: #222222; font-family: arial, sans-serif; font-size: 12.8px;"&gt;I attached main.c in case you need to look at it.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337544"&gt;main.c.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2016 19:07:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590958#M34782</guid>
      <dc:creator>brentgreenwald</dc:creator>
      <dc:date>2016-07-19T19:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with setting CAN pins</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590959#M34783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; color: #606060; font-size: 14pt;"&gt;Hi Brent,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; color: #606060; font-size: 14pt;"&gt;you need to enable the clock for Port A, similarly to how it is done for Port D. That is (probably) why Port D works, but Port A is giving a hard fault.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: calibri, verdana, arial, sans-serif; color: #606060; font-size: 14pt;"&gt;Just add this line of code in before you mux your pins:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #606060; font-family: calibri, verdana, arial, sans-serif; font-size: 14pt;"&gt;CLOCK_EnableClock(kCLOCK_PortA);&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #606060; font-family: calibri, verdana, arial, sans-serif; font-size: 14pt;"&gt;Now a hard fault, simply put, is essentially something that happens when the ARM Cortex-M core recognizes that a set of error conditions have been fulfilled. You can think of it like an interrupt. When an ARM core detects an interrupt, it goes to an interrupt service routine. On a similar note, when an ARM core detects an error, it goes to a hard fault handler. This is why a hard fault is called an "unhandled interrupt", because an error "interrupts" the ARM core, which then tells the ARM core that it needs to go an interrupt service routine, which is in this case the hard fault.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #606060; font-family: calibri, verdana, arial, sans-serif; font-size: 14pt;"&gt;It really helps to step through your code and determine exactly what line of code is causing your hard fault, and from there you can work to debug it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #606060; font-family: calibri, verdana, arial, sans-serif; font-size: 14pt;"&gt;Hope this helps,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #606060; font-family: calibri, verdana, arial, sans-serif; font-size: 14pt;"&gt;Charles&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jul 2016 19:57:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590959#M34783</guid>
      <dc:creator>charlesasquith</dc:creator>
      <dc:date>2016-07-19T19:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with setting CAN pins</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590960#M34784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brent,&lt;/P&gt;&lt;P&gt;As Charles responded, you need to clock peripherals first before using it, otherwise a hard fault will happen.&lt;/P&gt;&lt;P&gt;In case you need to find out what is causing the hard fault, the following might help you:&lt;/P&gt;&lt;P&gt;&lt;A href="https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/" title="https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/"&gt;https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Basically it means that you install a custom handler where you can get PC/cause of the fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the muxing: there is the NXP (Kinetis Expert) Pins tool which does the additional checks and as well turns on the clocks for you. See &lt;A href="https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/" title="https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/"&gt;https://mcuoneclipse.com/2016/07/19/nxp-pins-tool-clock-gates-and-controlling-the-bits/&lt;/A&gt;&amp;nbsp; and &lt;A href="https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/" title="https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/"&gt;https://mcuoneclipse.com/2016/06/08/tutorial-muxing-with-the-new-nxp-pins-tool/&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jul 2016 06:44:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Issue-with-setting-CAN-pins/m-p/590960#M34784</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2016-07-20T06:44:43Z</dc:date>
    </item>
  </channel>
</rss>

