<?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: KL26Z How can my app write/read to a reserved FLASH segment?</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015111#M56167</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bruce,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your detailed previous response, I believe that is a useful reference for other users of the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In order to use the SDK flash drivers in a the specific sector you will need to specify the destination address, that you will use to erase or write.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the&amp;nbsp;flash memory of&amp;nbsp;your device has 256KB of and has sectors (pages) of 1KB of size, it has 256 sectors, and the last sectors are located in the higher addresses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you import the&amp;nbsp; SDK example p-flash.&amp;nbsp; You will notice that the example erases in the last sector of the flash memory because implements the following sentence to calculate the destination address of the sector that is going to be erased.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;destAdrss = pflashBlockBase + (pflashTotalSize - (SECTOR_INDEX_FROM_END * pflashSectorSize));&lt;/P&gt;&lt;P&gt;Since&amp;nbsp;&amp;nbsp;&amp;nbsp;pflashBlockBase =0 ,&amp;nbsp;pFlashTotalSize 256Kb ,&amp;nbsp;&amp;nbsp;SECTOR_INDEX_FROM_END =1 and&amp;nbsp;pFlashSectorSize is 1kB.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;destAdrss =&amp;nbsp;0x0000&amp;nbsp;+ (0x4_0000&amp;nbsp;- (1 * 0x400));&lt;/P&gt;&lt;P&gt;destAdrss is 0x3fc00.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The&amp;nbsp;sentence&amp;nbsp;could be used to erase the desired flash sector, that is going to be used to write. If you modify the macro&amp;nbsp;SECTOR_INDEX_FROM_END you could refer to another sector from the end,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P lang="es-MX"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Diego&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Feb 2020 17:27:55 GMT</pubDate>
    <dc:creator>diego_charles</dc:creator>
    <dc:date>2020-02-18T17:27:55Z</dc:date>
    <item>
      <title>KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015106#M56162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;MCUXpresso IDE v11.0.1 [Build 2563] [2019-09-01]&lt;/SPAN&gt;&lt;BR clear="none" style="color: #696969; background-color: #ffffff; font-size: 13px;" /&gt;&lt;SPAN style="background-color: #ffffff; color: #696969; font-size: 13px; "&gt;MCU: MKL26Z256VLH4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;I would like to store run-time configuration information in the &lt;SPAN&gt;MCU's&amp;nbsp;&lt;/SPAN&gt;internal FLASH.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;The FLASH will be written to less then 10 times for the life of the product.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;In other MCUs, I could define a section in the FLASH that the linker and compiler would then reserve.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;Can I set up a FLASH area in MCUXpresso, or do I have to bit bang this all out?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #696969; background-color: #ffffff; font-size: 13px;"&gt;Bruce Graham&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2020 19:20:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015106#M56162</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2020-02-11T19:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015107#M56163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't usually need to reserve anything in the linker script. If your program is not using all the sectors simply using the top one or two for parameters already means that they are not used by the program. [If your program were to be using all sectors it wouldn't be possible anyway....]&lt;BR /&gt;To read them you can simply use a pointer to the memory:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;#define PARAMETER_LOCATION&amp;nbsp; (SIZE_OF_FLASH - SIZE_OF_FLASH_SECTOR)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;unsigned char local_parameters[SIZE_OF_PARAMETERS]; // local copy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;memcpy(local_parameters, (const void *)PARAMETER_LOCATION, sizeof(local_parameters)); // retrieve parameters&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The linker needs to know nothing of this and it is then fully portable in case you change compiler etc. To make the area larger at some point&amp;nbsp;&lt;SPAN style="font-family: courier new, courier, monospace;"&gt;#define PARAMETER_LOCATION&amp;nbsp; (SIZE_OF_FLASH - (2 * SIZE_OF_FLASH_SECTOR))&lt;/SPAN&gt; would already do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To write you can do the same (in the opposite direction) if you have a flashing function that accepts the flash destination location, although you will need to first delete the sector to make changes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the uTasker project we have a fail safe parameter system as standard (using a swap block to avoid loss of config data in case there were a power fail during the save) which you can compare if you need a truly robust solution; it also allows extending to a file system:&lt;BR /&gt;&lt;A href="https://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF" target="test_blank"&gt;https://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KL26 binary including the operation at &lt;A href="https://www.utasker.com/kinetis/FRDM-KL26Z.html" target="test_blank"&gt;https://www.utasker.com/kinetis/FRDM-KL26Z.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Source on GITHUB and allows flashing operation to be fully emulated in Visual Studio in case you want to copy the ideas and reference code.&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;BR /&gt;&lt;EM&gt;[uTasker project developer for Kinetis and i.MX RT]&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2020 23:04:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015107#M56163</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2020-02-11T23:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015108#M56164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Hello, Bruce&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the MCUxpresso you could add and split flash areas by doing a right-click on the project, then click on properties.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture_flash_split.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/97724i0D1EC4F953CBC8E4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture_flash_split.PNG" alt="Capture_flash_split.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After doing a split for example you could&amp;nbsp; specify the amount of space and then apply and close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="split_mem.PNG"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/97762i622EEED441C4E935/image-size/large?v=v2&amp;amp;px=999" role="button" title="split_mem.PNG" alt="split_mem.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope this information helps you. If you need more assistance please let us know!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, Charles&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2020 23:48:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015108#M56164</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2020-02-11T23:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015109#M56165</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Diego,&lt;/P&gt;&lt;P&gt;but the FLASH can't be&amp;nbsp;written to&amp;nbsp;from code running from FLASH, so must run from SRAM.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the KL26 SDK with my KL16 MCU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I defined a APP_FLASH_1KB in&amp;nbsp;Properties | C/C++ Build | MCU settings.&lt;/P&gt;&lt;P&gt;address=0x0003FC00, size=0x400&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the debugger's memory window, I can see the top of FLASH at 0x0003FC00.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;0x0003FC00 to&amp;nbsp;0x00040000 is filled with 0xFF.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used the&amp;nbsp;debugger's memory window to set 0x01020304 at&amp;nbsp;0x0003FC00.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace; "&gt;0x0003FC00 01020304 FFFFFFFF FFFFFFFF FFFFFFFF ....ÿÿÿÿÿÿÿÿÿÿÿÿ&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: 'courier new', courier, monospace; "&gt;0x0003FC10 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;memcpy() from&amp;nbsp;&lt;SPAN&gt;0x0003FC00 returns&lt;/SPAN&gt; &lt;SPAN&gt;0x01020304, so the memcpy() worked&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;memcpy() to&amp;nbsp;0x0003FC00&lt;/SPAN&gt;, generates a Hard Fault, IPSR = 0x3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The buffer used by memcpy() is aligned on the 32-bit address 0x1ffffc40, so I doubt the Hard Fault was caused by an alignment fault.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read&lt;/P&gt;&lt;P&gt;KL16 Sub-Family Reference Manual, Rev. 3.2, October 2013, and&lt;/P&gt;&lt;P&gt;Production Flash Programming Best Practices for Kinetis K- and L-series MCUs, Rev 1, 05/2014, and&lt;/P&gt;&lt;P&gt;Avoiding Read While Write Errors When Developing In-Software Flash Programming Applications for Kinetis and ColdFire+ MCUs, Rev. 0, 04/2013, and&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kinetis SDK v.2.0 API Reference Manual&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got it to work using the SDK APIs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;main()&lt;/P&gt;&lt;P&gt;&amp;nbsp; init()&lt;/P&gt;&lt;P&gt;&amp;nbsp; read()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;init()&lt;/P&gt;&lt;P&gt;FLASH_Init(&amp;amp;m_flashDriver);&lt;/P&gt;&lt;P&gt;FLASH_GetProperty(&amp;amp;m_flashDriver, kFLASH_PropertyPflash0BlockBaseAddr, &amp;amp;iflashBlockBase);&lt;BR /&gt; FLASH_GetProperty(&amp;amp;m_flashDriver, kFLASH_PropertyPflash0TotalSize, &amp;amp;iflashTotalSize);&lt;BR /&gt; FLASH_GetProperty(&amp;amp;m_flashDriver, kFLASH_PropertyPflash0SectorSize, &amp;amp;m_iflashSectorSize);&lt;/P&gt;&lt;P&gt;&amp;nbsp;m_destAdrss = iflashBlockBase + (iflashTotalSize - m_iflashSectorSize);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read()&lt;/P&gt;&lt;P&gt;memcpy((void *)&amp;amp;m_AppSettingsInFLASH, (const void *)m_destAdrss, sizeof(T_APP_SETTING_IN_FLASH));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write()&lt;/P&gt;&lt;P&gt;FLASH_GetSecurityState(&amp;amp;m_flashDriver, &amp;amp;securityStatus);&lt;/P&gt;&lt;P&gt;FLASH_Erase(&amp;amp;m_flashDriver, m_destAdrss, m_iflashSectorSize, kFLASH_ApiEraseKey);&lt;/P&gt;&lt;P&gt;FLASH_VerifyErase(&amp;amp;m_flashDriver, m_destAdrss, m_iflashSectorSize, kFTFx_MarginValueUser);&lt;/P&gt;&lt;P&gt;FLASH_Program(&amp;amp;m_flashDriver, m_destAdrss, (uint8_t*)&amp;amp;m_AppSettingsInFLASH, sizeof(T_APP_SETTING_IN_FLASH));&lt;/P&gt;&lt;P&gt;FLASH_VerifyProgram(&amp;amp;m_flashDriver, m_destAdrss, sizeof(T_APP_SETTING_IN_FLASH), (uint8_t*)&amp;amp;m_AppSettingsInFLASH, kFTFx_MarginValueUser,&amp;amp;failAddr, &amp;amp;failDat);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Feb 2020 22:20:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015109#M56165</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2020-02-12T22:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015110#M56166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Diego,&lt;/P&gt;&lt;P&gt;You created a FLASH "area" that is named "Flash2".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do the SDK FLASH APIs use the new  FLASH "area" that is named "Flash2"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Tue, Feb 11, 2020 at 6:49 PM diego.charles &amp;lt;admin@community.nxp.com&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2020 17:28:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015110#M56166</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2020-02-13T17:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: KL26Z How can my app write/read to a reserved FLASH segment?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015111#M56167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bruce,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your detailed previous response, I believe that is a useful reference for other users of the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In order to use the SDK flash drivers in a the specific sector you will need to specify the destination address, that you will use to erase or write.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the&amp;nbsp;flash memory of&amp;nbsp;your device has 256KB of and has sectors (pages) of 1KB of size, it has 256 sectors, and the last sectors are located in the higher addresses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you import the&amp;nbsp; SDK example p-flash.&amp;nbsp; You will notice that the example erases in the last sector of the flash memory because implements the following sentence to calculate the destination address of the sector that is going to be erased.&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;destAdrss = pflashBlockBase + (pflashTotalSize - (SECTOR_INDEX_FROM_END * pflashSectorSize));&lt;/P&gt;&lt;P&gt;Since&amp;nbsp;&amp;nbsp;&amp;nbsp;pflashBlockBase =0 ,&amp;nbsp;pFlashTotalSize 256Kb ,&amp;nbsp;&amp;nbsp;SECTOR_INDEX_FROM_END =1 and&amp;nbsp;pFlashSectorSize is 1kB.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;destAdrss =&amp;nbsp;0x0000&amp;nbsp;+ (0x4_0000&amp;nbsp;- (1 * 0x400));&lt;/P&gt;&lt;P&gt;destAdrss is 0x3fc00.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The&amp;nbsp;sentence&amp;nbsp;could be used to erase the desired flash sector, that is going to be used to write. If you modify the macro&amp;nbsp;SECTOR_INDEX_FROM_END you could refer to another sector from the end,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P lang="es-MX"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P lang="es-MX" style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Diego&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt; Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Feb 2020 17:27:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/KL26Z-How-can-my-app-write-read-to-a-reserved-FLASH-segment/m-p/1015111#M56167</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2020-02-18T17:27:55Z</dc:date>
    </item>
  </channel>
</rss>

