<?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>Kinetis MicrocontrollersのトピックRe: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657870#M40323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to identify hard fault problems you should step the failing code in disassemble mode. You will get to a line that hard faults and you can check the assembler code to see which address was written/read. This is usually seen as [r0] for example, where the value in r0 is the pointer.&lt;BR /&gt;There are 4 possibilities:&lt;BR /&gt;- the pointer is misaligned (not an issue on m4 parts but causes hard fault on m0+). Eg. a long word access to an uneven address&lt;BR /&gt;- the access to a byte register is being performed as a word (too wide)&lt;BR /&gt;- the memory doesn't exist (bad pointer)&lt;BR /&gt;- the peripheral register being accessed is not enabled (clock missing)&lt;BR /&gt;&lt;BR /&gt;The first 3 should be obvious and then the reasons for the difference can be seen by repeating/comparing with operational&amp;nbsp; and non-operational code.&lt;/P&gt;&lt;P&gt;In the 4th case use the peripheral register display to see whether the debugger can access the registers. If it can't the peripheral is probably not powered up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your case is strange since optimised code tends to fail in some cases whereas 'debug' - non-optimised code - has less risk, and therefore I don't have any suggestion as to what causes it but using the technique above it should become obvious with a few minutes work. I have used the technique hundreds of times and typically the reason is identified almost immediately.&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jan 2017 15:20:15 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2017-01-05T15:20:15Z</dc:date>
    <item>
      <title>KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657865#M40318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using Kinetis Studio&amp;nbsp;3.2.0.&lt;/P&gt;&lt;P&gt;Using OpenOCD to flash/debug the KL17.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using a Debug build the following line of code causes unexpected execution and hard faults.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;I2C0-&amp;gt;C1 |= I2C_C1_MST_MASK;&lt;/PRE&gt;&lt;P&gt;When using a Release build this does not occur.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on what the root cause of this. &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2017 00:46:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657865#M40318</guid>
      <dc:creator>rbowen</dc:creator>
      <dc:date>2017-01-04T00:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657866#M40319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan Bowen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Before you do the I2C0 operation, did you enable the I2C0 clock gate?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Please check register SIM_SCGC4[I2C0], you need to enable it, otherwise, when you do the I2C0 operation, the mcu will enter hardfault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;If you still have question, please let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2017 04:39:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657866#M40319</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-01-04T04:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657867#M40320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kerry, &lt;BR /&gt;Yes I have enabled the clock gate and clock source. For clarification below is my init code for both modules. I have the 48 pin package of the KL17.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;SIM-&amp;gt;SCGC5 |= SIM_SCGC5_PORTE_MASK | SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTC_MASK;
PORTE-&amp;gt;PCR[24] = PORT_PCR_MUX(0x5u);
PORTE-&amp;gt;PCR[25] = PORT_PCR_MUX(0x5u);
PORTC-&amp;gt;PCR[1] = PORT_PCR_MUX(0x2u);
PORTA-&amp;gt;PCR[4] = PORT_PCR_MUX(0x2u);
PORTE-&amp;gt;PCR[24] &amp;amp;= ~(PORT_PCR_PE_MASK);
PORTE-&amp;gt;PCR[25] &amp;amp;= ~(PORT_PCR_PE_MASK);
PORTC-&amp;gt;PCR[1] &amp;amp;= ~(PORT_PCR_PE_MASK);
PORTA-&amp;gt;PCR[4] &amp;amp;= ~(PORT_PCR_PE_MASK);
SIM-&amp;gt;SCGC4 |= SIM_SCGC4_I2C0_MASK | SIM_SCGC4_I2C1_MASK;
I2C0-&amp;gt;F = I2C_F_MULT(0x00) | I2C_F_ICR(0x18);
I2C1-&amp;gt;F = I2C_F_MULT(0x00) | I2C_F_ICR(0x18);
I2C0-&amp;gt;C1 = I2C_C1_IICEN_MASK;
I2C1-&amp;gt;C1 = I2C_C1_IICEN_MASK;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some time later I attempt to enter master mode to generate a start condition. The same code runs in Release does not hard fault. Debug crashes with or without any breakpoints. I have used this code in KEIL without any issue, when run in Kinetis Studio under debug there are problems.&amp;nbsp;&lt;/P&gt;&lt;PRE style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I2C0-&amp;gt;C1 |= I2C_C1_MST_MASK;&lt;/PRE&gt;&lt;P&gt;The issue appears to be isolated to I2C0, as the following is fine in Debug and Release modes.&lt;/P&gt;&lt;PRE style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I2C1-&amp;gt;C1 |= I2C_C1_MST_MASK;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2017 12:26:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657867#M40320</guid>
      <dc:creator>rbowen</dc:creator>
      <dc:date>2017-01-04T12:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657868#M40321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan Bowen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you are convenient, please attached your problem project. You can delete the code which you think is important to you, just leave the I2C code which can reproduce the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please tell me the full name of your chip.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I need to check it on my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 06:11:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657868#M40321</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-01-05T06:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657869#M40322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have stripped down a project to just the bare essentials all application code is included in main.c&lt;/P&gt;&lt;P&gt;Attached is the archived project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am referencing KSDK_2.1.0_GA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have highlighted the problem line in function&amp;nbsp;I2C_ping contained in main.c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am very curious if you are able to duplicate this issue.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 14:35:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657869#M40322</guid>
      <dc:creator>rbowen</dc:creator>
      <dc:date>2017-01-05T14:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657870#M40323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to identify hard fault problems you should step the failing code in disassemble mode. You will get to a line that hard faults and you can check the assembler code to see which address was written/read. This is usually seen as [r0] for example, where the value in r0 is the pointer.&lt;BR /&gt;There are 4 possibilities:&lt;BR /&gt;- the pointer is misaligned (not an issue on m4 parts but causes hard fault on m0+). Eg. a long word access to an uneven address&lt;BR /&gt;- the access to a byte register is being performed as a word (too wide)&lt;BR /&gt;- the memory doesn't exist (bad pointer)&lt;BR /&gt;- the peripheral register being accessed is not enabled (clock missing)&lt;BR /&gt;&lt;BR /&gt;The first 3 should be obvious and then the reasons for the difference can be seen by repeating/comparing with operational&amp;nbsp; and non-operational code.&lt;/P&gt;&lt;P&gt;In the 4th case use the peripheral register display to see whether the debugger can access the registers. If it can't the peripheral is probably not powered up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your case is strange since optimised code tends to fail in some cases whereas 'debug' - non-optimised code - has less risk, and therefore I don't have any suggestion as to what causes it but using the technique above it should become obvious with a few minutes work. I have used the technique hundreds of times and typically the reason is identified almost immediately.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2017 15:20:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657870#M40323</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-01-05T15:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: KL17 Crashes When Setting Master Mode in Kinetis Studio Debug</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657871#M40324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan Bowen,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have test your attached project directly on my side.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; It works ok on my side, no hardfault happens no matter I use breakpoint or without the break point in the debug mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; This is my test wave:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/7217i74E023767BDF9E94/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; You can try to clean the project, then build again and test it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Besides, you also can refer to this post:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" 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;Debugging Hard Faults on ARM Cortex-M | MCU on Eclipse&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; To check what is the root code which caused enter in the hardfault.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Please also check your chip part number, the project you give me is used for:&lt;/P&gt;&lt;P&gt;**&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Processors:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MKL17Z128VFM4&lt;BR /&gt;**&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; MKL17Z128VFT4&lt;BR /&gt;**&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; MKL17Z128VLH4&lt;BR /&gt;**&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; MKL17Z128VMP4&lt;BR /&gt;**&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; MKL17Z256VFM4&lt;BR /&gt;**&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; MKL17Z256VFT4&lt;BR /&gt;**&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; MKL17Z256VLH4&lt;BR /&gt;**&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; MKL17Z256VMP4&lt;BR /&gt;**&lt;/P&gt;&lt;P&gt;Not for KL17 32K and 64K flash chip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&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;BR /&gt;Have a great day,&lt;BR /&gt;Kerry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 02:33:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL17-Crashes-When-Setting-Master-Mode-in-Kinetis-Studio-Debug/m-p/657871#M40324</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2017-01-09T02:33:13Z</dc:date>
    </item>
  </channel>
</rss>

