<?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 KEAZ64 always reset in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEAZ64-always-reset/m-p/607916#M35876</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my KEAZ64 project , when I reference to a pointer , the MCU will reset . &amp;nbsp;&lt;/P&gt;&lt;P&gt;I have traced the code ,found the value is correct . &amp;nbsp;But once step to the line :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN style="color: #ff0000;"&gt;nTblSize = pTSAInfo-&amp;gt;tblSize;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the MCU will reset .&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Double check the code , NOT found what's wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried in KDS and CW 10.7 ,got the same result .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help to check it .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simplify all the code &amp;nbsp;in one file &amp;nbsp; to demo the issue &amp;nbsp;as following:&lt;/P&gt;&lt;P&gt;And also attached the KDS project file.&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * Copyright (c) 2015, Freescale Semiconductor, Inc.&lt;BR /&gt; * All rights reserved.&lt;BR /&gt; *&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;#include "SKEAZ1284.h"&lt;/P&gt;&lt;P&gt;static int i = 0;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;typedef unsigned char FMSTR_U8;&lt;BR /&gt;typedef unsigned short FMSTR_U16;&lt;/P&gt;&lt;P&gt;typedef unsigned char *FMSTR_ADDR;&lt;BR /&gt;typedef unsigned char FMSTR_BCHR;&lt;BR /&gt;typedef unsigned char* FMSTR_BPTR;&lt;/P&gt;&lt;P&gt;typedef unsigned char BOOL;&lt;BR /&gt;typedef unsigned char BYTE;&lt;BR /&gt;typedef unsigned short WORD;&lt;BR /&gt;typedef unsigned long DWORD;&lt;BR /&gt;typedef void * LPVOID;&lt;/P&gt;&lt;P&gt;#define NULL 0&lt;/P&gt;&lt;P&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt; //feed para&lt;/P&gt;&lt;P&gt;FMSTR_U8 cmd; //command code ,the response is for this cmd&lt;BR /&gt; FMSTR_U8 len; // command data len&lt;BR /&gt; FMSTR_U8 subitem; // sub imtem&lt;BR /&gt; FMSTR_U8 ReadMemEX_Size; // size for readMemEX&lt;BR /&gt; FMSTR_ADDR ReadMemEX_Addr; // address for readMemEX&lt;/P&gt;&lt;P&gt;FMSTR_BPTR pData; // point to data IO buffer&lt;BR /&gt; //return para&lt;BR /&gt; FMSTR_U8 status; //command return status&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;} MCB_RESP,*pMCB_RESP;&lt;/P&gt;&lt;P&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt; WORD tsaFlags;&lt;BR /&gt; WORD tblSize;&lt;BR /&gt; DWORD tblAddr;&lt;/P&gt;&lt;P&gt;} MCB_RESP_GETTSAINFOEX, * LPMCB_RESP_GETTSAINFOEX;&lt;/P&gt;&lt;P&gt;static FMSTR_BCHR pcm_pCommBuffer[67];&lt;BR /&gt;static MCB_RESP FMSTR_CMD_RESP;&lt;BR /&gt;static FMSTR_BPTR pcm_pRxBuff;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;/* Write your code here */&lt;BR /&gt; LPMCB_RESP_GETTSAINFOEX pTSAInfo;&lt;BR /&gt; pMCB_RESP pCmdResp =NULL;&lt;BR /&gt; MCB_RESP ** ppCmdResp;&lt;/P&gt;&lt;P&gt;FMSTR_U16 nTblSize;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; pcm_pRxBuff = pcm_pCommBuffer;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x02;&lt;BR /&gt; *pcm_pRxBuff++ = 0x01;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x02;&lt;BR /&gt; *pcm_pRxBuff++ = 0xEC;&lt;BR /&gt; *pcm_pRxBuff++ = 0x92;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x7D;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; FMSTR_CMD_RESP.pData = pcm_pCommBuffer+1;&lt;/P&gt;&lt;P&gt;ppCmdResp = &amp;amp; pCmdResp;&lt;BR /&gt; *ppCmdResp = &amp;amp; FMSTR_CMD_RESP;&lt;/P&gt;&lt;P&gt;pTSAInfo = (LPMCB_RESP_GETTSAINFOEX)(pCmdResp-&amp;gt;pData);&lt;BR /&gt; &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;nTblSize = pTSAInfo-&amp;gt;tblSize; &amp;nbsp;// Run to here, the MCU will reset&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* This for loop should be replaced. By default this loop allows a single stepping. */&lt;BR /&gt; for (;;) {&lt;BR /&gt; i++;&lt;BR /&gt; }&lt;BR /&gt; /* Never leave main */&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// EOF&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&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-337613"&gt;keaz64_t1.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Apr 2017 07:19:08 GMT</pubDate>
    <dc:creator>kigerzhang</dc:creator>
    <dc:date>2017-04-13T07:19:08Z</dc:date>
    <item>
      <title>KEAZ64 always reset</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEAZ64-always-reset/m-p/607916#M35876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my KEAZ64 project , when I reference to a pointer , the MCU will reset . &amp;nbsp;&lt;/P&gt;&lt;P&gt;I have traced the code ,found the value is correct . &amp;nbsp;But once step to the line :&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN style="color: #ff0000;"&gt;nTblSize = pTSAInfo-&amp;gt;tblSize;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the MCU will reset .&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Double check the code , NOT found what's wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried in KDS and CW 10.7 ,got the same result .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help to check it .&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simplify all the code &amp;nbsp;in one file &amp;nbsp; to demo the issue &amp;nbsp;as following:&lt;/P&gt;&lt;P&gt;And also attached the KDS project file.&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * Copyright (c) 2015, Freescale Semiconductor, Inc.&lt;BR /&gt; * All rights reserved.&lt;BR /&gt; *&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;#include "SKEAZ1284.h"&lt;/P&gt;&lt;P&gt;static int i = 0;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;typedef unsigned char FMSTR_U8;&lt;BR /&gt;typedef unsigned short FMSTR_U16;&lt;/P&gt;&lt;P&gt;typedef unsigned char *FMSTR_ADDR;&lt;BR /&gt;typedef unsigned char FMSTR_BCHR;&lt;BR /&gt;typedef unsigned char* FMSTR_BPTR;&lt;/P&gt;&lt;P&gt;typedef unsigned char BOOL;&lt;BR /&gt;typedef unsigned char BYTE;&lt;BR /&gt;typedef unsigned short WORD;&lt;BR /&gt;typedef unsigned long DWORD;&lt;BR /&gt;typedef void * LPVOID;&lt;/P&gt;&lt;P&gt;#define NULL 0&lt;/P&gt;&lt;P&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt; //feed para&lt;/P&gt;&lt;P&gt;FMSTR_U8 cmd; //command code ,the response is for this cmd&lt;BR /&gt; FMSTR_U8 len; // command data len&lt;BR /&gt; FMSTR_U8 subitem; // sub imtem&lt;BR /&gt; FMSTR_U8 ReadMemEX_Size; // size for readMemEX&lt;BR /&gt; FMSTR_ADDR ReadMemEX_Addr; // address for readMemEX&lt;/P&gt;&lt;P&gt;FMSTR_BPTR pData; // point to data IO buffer&lt;BR /&gt; //return para&lt;BR /&gt; FMSTR_U8 status; //command return status&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;} MCB_RESP,*pMCB_RESP;&lt;/P&gt;&lt;P&gt;typedef struct&lt;BR /&gt;{&lt;BR /&gt; WORD tsaFlags;&lt;BR /&gt; WORD tblSize;&lt;BR /&gt; DWORD tblAddr;&lt;/P&gt;&lt;P&gt;} MCB_RESP_GETTSAINFOEX, * LPMCB_RESP_GETTSAINFOEX;&lt;/P&gt;&lt;P&gt;static FMSTR_BCHR pcm_pCommBuffer[67];&lt;BR /&gt;static MCB_RESP FMSTR_CMD_RESP;&lt;BR /&gt;static FMSTR_BPTR pcm_pRxBuff;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;int main(void)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;/* Write your code here */&lt;BR /&gt; LPMCB_RESP_GETTSAINFOEX pTSAInfo;&lt;BR /&gt; pMCB_RESP pCmdResp =NULL;&lt;BR /&gt; MCB_RESP ** ppCmdResp;&lt;/P&gt;&lt;P&gt;FMSTR_U16 nTblSize;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; pcm_pRxBuff = pcm_pCommBuffer;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x02;&lt;BR /&gt; *pcm_pRxBuff++ = 0x01;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x02;&lt;BR /&gt; *pcm_pRxBuff++ = 0xEC;&lt;BR /&gt; *pcm_pRxBuff++ = 0x92;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x00;&lt;BR /&gt; *pcm_pRxBuff++ = 0x7D;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; FMSTR_CMD_RESP.pData = pcm_pCommBuffer+1;&lt;/P&gt;&lt;P&gt;ppCmdResp = &amp;amp; pCmdResp;&lt;BR /&gt; *ppCmdResp = &amp;amp; FMSTR_CMD_RESP;&lt;/P&gt;&lt;P&gt;pTSAInfo = (LPMCB_RESP_GETTSAINFOEX)(pCmdResp-&amp;gt;pData);&lt;BR /&gt; &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;nTblSize = pTSAInfo-&amp;gt;tblSize; &amp;nbsp;// Run to here, the MCU will reset&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; /* This for loop should be replaced. By default this loop allows a single stepping. */&lt;BR /&gt; for (;;) {&lt;BR /&gt; i++;&lt;BR /&gt; }&lt;BR /&gt; /* Never leave main */&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&lt;BR /&gt;// EOF&lt;BR /&gt;////////////////////////////////////////////////////////////////////////////////&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-337613"&gt;keaz64_t1.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Apr 2017 07:19:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEAZ64-always-reset/m-p/607916#M35876</guid>
      <dc:creator>kigerzhang</dc:creator>
      <dc:date>2017-04-13T07:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: KEAZ64 always reset</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEAZ64-always-reset/m-p/607917#M35877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Cortex m0+ (in KEA) can't access unaligned addresses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code is assigning an unaligned address to a struct pointer and so when&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;nTblSize = pTSAInfo-&amp;gt;tblSize;&amp;nbsp; // Run to here, the MCU will reset&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;is executed it will be trying to read a short word from an unaligned address in RAM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the line that more or less forces the failure:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FMSTR_CMD_RESP.pData = pcm_pCommBuffer + 1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;as pcm_pCommBuffer[] is very probably aligned to start on a long word boundary (but possibly not guaranteed) so you are forcing a misaligned struct pointer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cortex m4 will work since it supports misaligned addressing (but is slower in the process).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore it is not a compiler or IDE problem but incorrect code design in a Cortex m0+ environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will need to rework the buffer design to ensure that if you want to access using struct pointers that the byte array memory is suitably (and guaranteed ) aligned. Alternatively you could do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;typedef struct&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char tsaFlags[2];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned char tblSize[2];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long tblAddr[4];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;} MCB_RESP_GETTSAINFOEX, *LPMCB_RESP_GETTSAINFOEX;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;nTblSize = ((pTSAInfo-&amp;gt;tblSize[0] &amp;lt;&amp;lt; 8) | pTSAInfo-&amp;gt;tblSize[1]);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to ensure no access risks but it is a bit fiddly and less efficient (but very safe and unconditionally portable).&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;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>Thu, 13 Apr 2017 12:34:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KEAZ64-always-reset/m-p/607917#M35877</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-04-13T12:34:05Z</dc:date>
    </item>
  </channel>
</rss>

