<?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: FTFL Program LongWord behavior in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316985#M13992</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;span class="lia-inline-image-display-wrapper" image-alt="Flash_end.PNG.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/44477iA38C7FBDFDA7D1AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Flash_end.PNG.png" alt="Flash_end.PNG.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This may be correct but also confusing. The FCCOB register bytes are implemented in little-endian storage which then swaps it around again. On the other hand it may also be wrong and it should state that it uses a little-endian addressing convention(?).&lt;/P&gt;&lt;P&gt;In any case the flash controllers in all parts is the same in this respect, so it is always possible to write a long word directly when addressing the FCCOB registers as long words (like FTFL_FCCOB7_4) as you have done.&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>Wed, 11 Jun 2014 06:07:44 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2014-06-11T06:07:44Z</dc:date>
    <item>
      <title>FTFL Program LongWord behavior</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316984#M13991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The datasheet for the MK10DX256VLH7 states that the Program LongWord command will program FCCOB4 to FCCOB7 to addresses n to n+3, but when I check it, the word written has the bytes swapped.&lt;/P&gt;&lt;P&gt;It means I have to program:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14024396898747450" jivemacro_uid="_14024396898747450"&gt;
&lt;P&gt;enum { FTFL_ProgramLongWord = 0x06};&lt;/P&gt;
&lt;P&gt;void programWord(&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt; int address, uint32_t value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB0 = FTFL_ProgramLongWord;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB1 = address &amp;gt;&amp;gt; 16;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB2 = address &amp;gt;&amp;gt;&amp;nbsp; 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB3 = address &amp;gt;&amp;gt;&amp;nbsp; 0;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB4 = value &amp;gt;&amp;gt; 24;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB5 = value &amp;gt;&amp;gt; 16;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB6 = value &amp;gt;&amp;gt;&amp;nbsp; 8;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; FTFL_BASE_PTR-&amp;gt;FCCOB7 = value &amp;gt;&amp;gt;&amp;nbsp; 0;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; // start command and wait for completion&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Digging deeper, I noticed as well the definition in KM10D7.h, which has a byte swapped ordered FCCOB declaration, contradicting the order described in the datasheet.&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14024396898535034 jive_text_macro jive_macro_code" jivemacro_uid="_14024396898535034" modifiedtitle="true"&gt;
&lt;P&gt;typedef struct FTFL_MemMap {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FSTAT;&amp;nbsp;&amp;nbsp; /**&amp;lt; Flash Status Register, offset: 0x0 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCNFG;&amp;nbsp;&amp;nbsp; /**&amp;lt; Flash Configuration Register, offset: 0x1 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FSEC;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; Flash Security Register, offset: 0x2 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FOPT;&amp;nbsp;&amp;nbsp;&amp;nbsp; /**&amp;lt; Flash Option Register, offset: 0x3 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB3;&amp;nbsp; /**&amp;lt; Flash Common Command Object Registers, offset: 0x4 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB2; /**&amp;lt; Flash Common Command Object Registers, offset: 0x5 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB1; /**&amp;lt; Flash Common Command Object Registers, offset: 0x6 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB0; /**&amp;lt; Flash Common Command Object Registers, offset: 0x7 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB7; /**&amp;lt; Flash Common Command Object Registers, offset: 0x8 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB6; /**&amp;lt; Flash Common Command Object Registers, offset: 0x9 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB5; /**&amp;lt; Flash Common Command Object Registers, offset: 0xA */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB4; /**&amp;lt; Flash Common Command Object Registers, offset: 0xB */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOBB; /**&amp;lt; Flash Common Command Object Registers, offset: 0xC */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOBA; /**&amp;lt; Flash Common Command Object Registers, offset: 0xD */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB9; /**&amp;lt; Flash Common Command Object Registers, offset: 0xE */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FCCOB8; /**&amp;lt; Flash Common Command Object Registers, offset: 0xF */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FPROT3; /**&amp;lt; Program Flash Protection Registers, offset: 0x10 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FPROT2; /**&amp;lt; Program Flash Protection Registers, offset: 0x11 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FPROT1; /**&amp;lt; Program Flash Protection Registers, offset: 0x12 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FPROT0; /**&amp;lt; Program Flash Protection Registers, offset: 0x13 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t RESERVED_0[2];&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FEPROT; /**&amp;lt; EEPROM Protection Register, offset: 0x16 */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; uint8_t FDPROT; /**&amp;lt; Data Flash Protection Register, offset: 0x17 */&lt;/P&gt;
&lt;P&gt;} volatile *FTFL_MemMapPtr;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which means that one could do the programming of a long word as follows:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1402439689844649" jivemacro_uid="_1402439689844649"&gt;
&lt;P&gt;typedef struct FTFL_WordMap {&lt;/P&gt;
&lt;P&gt;int&amp;nbsp; :32;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; uint32_t FCCOB_3_0;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; uint32_t FCCOB_7_4;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; uint32_t FCCOB_B_8;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; int :32;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp; int :32;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;} volatile *FTFL_WordMapPtr;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;
&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;enum { FTFL_ProgramLongWord = 0x06};&lt;/P&gt;
&lt;P&gt;void programWord(&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt; int address, uint32_t value)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;FTFL_WordMapPtr&lt;/SPAN&gt;* pWordBase = (&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;FTFL_WordMapPtr&lt;/SPAN&gt;) FTFL_BASE_PTR;&lt;/P&gt;
&lt;P&gt;pWordBase-&amp;gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;FCCOB_3_0&lt;/SPAN&gt; = F&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;TFL_ProgramLongWord&lt;/SPAN&gt; &amp;lt;&amp;lt; 24 | ( address &amp;amp; ( ( 1&amp;lt;&amp;lt;24) - 1));&lt;/P&gt;
&lt;P&gt;pWordBase-&amp;gt;FCCOB_7_4 = value;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt; ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do these issues extend to all Kinetis processors utilizing the FTFL or FTFE flash module?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2014 22:34:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316984#M13991</guid>
      <dc:creator>Laartoor</dc:creator>
      <dc:date>2014-06-10T22:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: FTFL Program LongWord behavior</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316985#M13992</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;span class="lia-inline-image-display-wrapper" image-alt="Flash_end.PNG.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/44477iA38C7FBDFDA7D1AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Flash_end.PNG.png" alt="Flash_end.PNG.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This may be correct but also confusing. The FCCOB register bytes are implemented in little-endian storage which then swaps it around again. On the other hand it may also be wrong and it should state that it uses a little-endian addressing convention(?).&lt;/P&gt;&lt;P&gt;In any case the flash controllers in all parts is the same in this respect, so it is always possible to write a long word directly when addressing the FCCOB registers as long words (like FTFL_FCCOB7_4) as you have done.&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>Wed, 11 Jun 2014 06:07:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316985#M13992</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-06-11T06:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: FTFL Program LongWord behavior</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316986#M13993</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 old version (vBeta033) FTFL Programlongword driver with below info, which according to Kinetis product Endianness select FCCOB[4~7] data.&lt;/P&gt;&lt;P&gt;Please check below code:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;/* check for error return code */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if(FTFx_OK == returnCode)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;while(size &amp;gt; 0)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;{&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;/* preparing passing parameter to program the flash block */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[0] = FTFx_PROGRAM_LONGWORD;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[1] = (UINT8)(destination &amp;gt;&amp;gt; 16);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[2] = (UINT8)((destination &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[3] = (UINT8)(destination &amp;amp; 0xFF);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt; &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;#if (ENDIANNESS == BIG_ENDIAN)&amp;nbsp; /* Big Endian */&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[4] = READ8(source);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[5] = READ8(source + 1);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[6] = READ8(source + 2);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[7] = READ8(source + 3);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;#else /* Little Endian */&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[4] = READ8(source + 3);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[5] = READ8(source + 2);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[6] = READ8(source + 1);&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;pCommandArray[7] = READ8(source);&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;#endif&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also attached the whole FTFL Programlongword driver for your reference.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Wish it help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;BR /&gt;Ma Hui&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, 11 Jun 2014 09:38:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FTFL-Program-LongWord-behavior/m-p/316986#M13993</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-06-11T09:38:37Z</dc:date>
    </item>
  </channel>
</rss>

