<?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>CodeWarrior Development ToolsのトピックRe: Kinetis MCU bugs when using malloc and structure, go to Default ISR</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648751#M5684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forget, the problematic lines are :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;But I think to see the problem, the result of the allocation is on the ISR vectors&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Malloc_issue.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9968i89EFBCA859752666/image-size/large?v=v2&amp;amp;px=999" role="button" title="Malloc_issue.jpg" alt="Malloc_issue.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;How can I avoid this ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Dec 2016 13:15:37 GMT</pubDate>
    <dc:creator>samc</dc:creator>
    <dc:date>2016-12-05T13:15:37Z</dc:date>
    <item>
      <title>Kinetis MCU bugs when using malloc and structure, go to Default ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648750#M5683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use a MKL17Z256 Kinetis MCU and I have a problem with a code with dynamic allocation.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All is OK when I use this code :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: 10.0pt;"&gt;&lt;STRONG&gt;typedef&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #7f0055; font-size: 10.0pt;"&gt;&lt;STRONG&gt;struct&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;unsigned char &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;unsigned short &lt;/SPAN&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; Test_STR;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; * PointeurTest_STR = &amp;amp;Test_STR;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;PointeurTest_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;PointeurTest_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;But MCU buggs when I use this one:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7f0055; font-size: 10.0pt;"&gt;&lt;STRONG&gt;typedef&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #7f0055; font-size: 10.0pt;"&gt;&lt;STRONG&gt;struct&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;unsigned char &lt;/SPAN&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;unsigned short &lt;/SPAN&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;* Test_STR = &lt;/SPAN&gt;&lt;SPAN style="color: #642880; font-size: 10.0pt;"&gt;&lt;STRONG&gt;malloc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #7f0055; font-size: 10.0pt;"&gt;&lt;STRONG&gt;sizeof&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #005032;"&gt;test_str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;The problem is the MCU fall in defaultISR in startup:MKL.....S file&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;DefaultISR:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp; &amp;nbsp;r0, =DefaultISR&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bx r0&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;What can cause this problem ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 11:44:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648750#M5683</guid>
      <dc:creator>samc</dc:creator>
      <dc:date>2016-12-05T11:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis MCU bugs when using malloc and structure, go to Default ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648751#M5684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forget, the problematic lines are :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U8&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Test_STR-&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #0000c0;"&gt;Test_U16&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;But I think to see the problem, the result of the allocation is on the ISR vectors&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Malloc_issue.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/9968i89EFBCA859752666/image-size/large?v=v2&amp;amp;px=999" role="button" title="Malloc_issue.jpg" alt="Malloc_issue.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;How can I avoid this ?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 13:15:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648751#M5684</guid>
      <dc:creator>samc</dc:creator>
      <dc:date>2016-12-05T13:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis MCU bugs when using malloc and structure, go to Default ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648752#M5685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the compiler/link options. &amp;nbsp;Replace -Os with -O2 if you are using GCC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The L family does not deal with unaligned accesses and the 'Small' model saves space by not aligning things.&lt;/P&gt;&lt;P&gt;This can make the code look like random faults as things are moved around. &amp;nbsp;Sometimes things end up aligned by accident and it will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Indirectly related it, in a structure it is better to put things from the largest to the smallest, that is reverse the unsigned char and unsigned short (better to use &amp;lt;stdint.h&amp;gt; types actually) in the test structure. &amp;nbsp;Placing things from small to big can waste a lot of memory due to hidden structure alignment bytes. &amp;nbsp;There are compiler options to pack the structures.&lt;BR /&gt;&lt;BR /&gt;Also check the linker script to see how much heap space is allocated. &amp;nbsp;Some of the default ones allocate no heap space and the stack collides with things leading to faults.&lt;/P&gt;&lt;P&gt;Perhaps this is why it looks like the heap is at zero in the IDE.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 13:38:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648752#M5685</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2016-12-05T13:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Kinetis MCU bugs when using malloc and structure, go to Default ISR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648753#M5686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It wasn't on -Os but -O0, but I changed it to -O2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I saw Heap Size was at 0x0000 and Heap Stack was at 0x0400. So I changed heap size to 0x0400 and it works well. I just saw in another post that change this heap size resolved the problem. Effectively it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noted your advise about structure configuration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 14:50:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Kinetis-MCU-bugs-when-using-malloc-and-structure-go-to-Default/m-p/648753#M5686</guid>
      <dc:creator>samc</dc:creator>
      <dc:date>2016-12-05T14:50:21Z</dc:date>
    </item>
  </channel>
</rss>

