<?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>LPC MicrocontrollersのトピックRe: LPC804 write flash single word</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1400999#M47675</link>
    <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;Thanks so much for all of your example code!&amp;nbsp; (I hope NXP is paying you something to provide the support we need &lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jan 2022 14:48:35 GMT</pubDate>
    <dc:creator>phatpaul</dc:creator>
    <dc:date>2022-01-18T14:48:35Z</dc:date>
    <item>
      <title>LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1398379#M47607</link>
      <description>&lt;P&gt;My nonvolatile storage driver needs to write 4 bytes at a time to an already erased sector (i.e. memory contents starts at &lt;STRIKE&gt;0xFFFFFFFF&lt;/STRIKE&gt; 0x0 before being written to once). When an entire sector is used up, then a garbage-collection routine erases the entire sector and it can begin to be written again.&lt;/P&gt;&lt;P&gt;When I called IAP_CopyRamToFlash() with size of 4 bytes, I got the error COUNT_ERROR (Byte count is not 64 | 128 | 256 | 512 | 1024).&lt;/P&gt;&lt;P&gt;I'm disappointed to find that the minimum write size for IAP flash is 64 bytes, not 4 bytes as I expected (and is possible with Kinetis).&lt;/P&gt;&lt;P&gt;It seems to be a shame if I have to buffer 64-bytes in RAM to read-modify-write just 4-bytes at a time.&lt;/P&gt;&lt;P&gt;Is it possible to workaround this limitation by loading the 64-byte buffer with all &lt;STRIKE&gt;0xFFFFFFFF&lt;/STRIKE&gt; 0x0 except for the word that I want to program at that time?&amp;nbsp; Will the other words be unaffected by the write and retain their value?&lt;/P&gt;&lt;P&gt;Is there an example of doing this?&lt;/P&gt;&lt;P&gt;EDIT: There's a similar unanswered question here: &lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-FLASH-write-disturbance/m-p/1020218" target="_blank" rel="noopener"&gt;https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-FLASH-write-disturbance/m-p/1020218&lt;/A&gt;&lt;/P&gt;&lt;P&gt;EDIT: Looks like the erased state of the flash is '0', not 0xFF.&amp;nbsp; I found a KB for LPC55xx (but not for LPC8xx) which confirms it: &lt;A href="https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC55xx-Erased-Memory-State-0-or-1/ta-p/1135084" target="_blank"&gt;https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC55xx-Erased-Memory-State-0-or-1/ta-p/1135084&lt;/A&gt;&amp;nbsp; That's going to cause more difficulty in porting my nonvolatile storage driver, but my question still stands.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 15:40:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1398379#M47607</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-13T15:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399014#M47623</link>
      <description>&lt;P&gt;I tested my theory by with an example program that tries to write successive words while leaving the others alone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added this to the end of the iap_flash.c in example project "lpcxpresso804_iap_flash":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    for (int woff = 0; woff &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; woff++)
    {
        memset(&amp;amp;s_PageBuf[0], 0, sizeof(s_PageBuf));
        s_PageBuf[woff] = 0x11111111 * woff;
        PRINTF("\r\nWriting flash sector %d:", DEMO_IAP_FLASH_SECTOR);
        for (i = 0; i &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; i++)
        {
            PRINTF(" %8X", s_PageBuf[i]);
        }
        /* write a page */
        IAP_PrepareSectorForWrite(DEMO_IAP_FLASH_SECTOR, DEMO_IAP_FLASH_SECTOR);
        IAP_CopyRamToFlash(s_IapFlashPage * FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES, &amp;amp;s_PageBuf[0],
                           FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES, SystemCoreClock);
        PRINTF("\r\nReading flash sector %d:", DEMO_IAP_FLASH_SECTOR);
        uint32_t *read_ptr = (s_IapFlashPage)*FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES;
        for (i = 0; i &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; i++)
        {
            PRINTF(" %8X", *read_ptr++);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expected the result to be 00000000 11111111 22222222 33333333 444444444 ....&lt;/P&gt;&lt;P&gt;Unfortunately it doesn't work as it appears that the chip is actually erasing the page each time.&amp;nbsp; So what's the point of telling us to do an explicit erase before writing then?&amp;nbsp; I wonder if that will actually do 2 erases?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0 11111111        0        0        0        0        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0 11111111        0        0        0        0        0        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0 22222222        0        0        0        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0 22222222        0        0        0        0        0        0        0        0        0        0        0        0        00
Writing flash sector 14:        0        0        0 33333333        0        0        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0        0 33333333        0        0        0        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0 44444444        0        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0        0        0 44444444        0        0        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0 55555555        0        0        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0        0        0        0 55555555        0        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0 66666666        0        0        0        0        0        0        0        0         0
Reading flash sector 14:        0        0        0        0        0        0 66666666        0        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0 77777777        0        0        0        0        0        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0 77777777        0        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0 88888888        0        0        0        0        0        0        0
Reading flash sector 14:         0        0        0        0        0        0         0        0 88888888        0        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0 99999999        0        0        0        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0 99999999        0        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0 AAAAAAAA        0        0        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0 AAAAAAAA        0        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0 BBBBBBBB        0        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0 BBBBBBBB        0        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0 CCCCCCCC        0        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0 CCCCCCCC        0        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0 DDDDDDDD        0        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0 DDDDDDDD        0        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0 EEEEEEEE        0
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0 EEEEEEEE        0
Writing flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0 FFFFFFFF
Reading flash sector 14:        0        0        0        0        0        0        0        0        0        0        0        0        0        0        0 FFFFFFFF&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 16:57:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399014#M47623</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-13T16:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399022#M47624</link>
      <description>&lt;P&gt;What happened to the reply I just posted??&amp;nbsp; I saw it posted then it disappeared.&amp;nbsp; This forum is so frustrating!&lt;/P&gt;&lt;P&gt;EDIT: Well my missing post just re-appeared a day later, after I retyped it and posted my answer.&amp;nbsp; So this thread may read a bit out-of-order.&amp;nbsp; Is it a moderator delay?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 14:51:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399022#M47624</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-18T14:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399053#M47625</link>
      <description>&lt;P&gt;I made a simple test program to test my theory.&amp;nbsp; If it works it should result in the page containing 00000000 11111111 22222222 333333333 ...&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Test overwrite page assuming erased state is 0x0
    for (int woff = 0; woff &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; woff++)
    {
        memset(&amp;amp;s_PageBuf[0], 0, sizeof(s_PageBuf));
        s_PageBuf[woff] = 0x11111111 * woff;
        PRINTF("\r\nWrite page %d:", s_IapFlashPage);
        for (i = 0; i &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; i++)
        {
            PRINTF(" %X", s_PageBuf[i]);
        }
        /* write a page */
        IAP_PrepareSectorForWrite(DEMO_IAP_FLASH_SECTOR, DEMO_IAP_FLASH_SECTOR);
        IAP_CopyRamToFlash(s_IapFlashPage * FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES, &amp;amp;s_PageBuf[0],
                           FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES, SystemCoreClock);
        PRINTF("\r\nRead page %d:", s_IapFlashPage);
        uint32_t *read_ptr = (s_IapFlashPage)*FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES;
        for (i = 0; i &amp;lt; FSL_FEATURE_SYSCON_FLASH_PAGE_SIZE_BYTES / 4; i++)
        {
            PRINTF(" %X", *read_ptr++);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, it doesn't do that.&amp;nbsp; It seems like the driver is doing an erase of the page before programming.&amp;nbsp; (So why do they tell us we have to do an explicit erase before programming anyway?)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Write page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 11111111 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 22222222 0 0 0 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 22222222 0 0 0 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 33333333 0 0 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 33333333 0 0 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 44444444 0 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 44444444 0 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 55555555 0 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 55555555 0 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 66666666 0 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 66666666 0 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 77777777 0 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 77777777 0 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 88888888 0 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 88888888 0 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 99999999 0 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 99999999 0 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 AAAAAAAA 0 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 AAAAAAAA 0 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 0 BBBBBBBB 0 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 BBBBBBBB 0 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 0 0 CCCCCCCC 0 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 0 CCCCCCCC 0 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 0 0  0 DDDDDDDD 0 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 DDDDDDDD 0 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 EEEEEEEE 0
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 EEEEEEEE 0
Write page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FFFFFFFF
Read page 224: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 FFFFFFFF&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found some example code from &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt; which shows how to buffer the page and do a read-modify-write.&amp;nbsp; &lt;A href="https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/minIni/McuFlash.c#L213" target="_blank"&gt;https://github.com/ErichStyger/McuOnEclipseLibrary/blob/master/lib/minIni/McuFlash.c#L213&lt;/A&gt;&amp;nbsp; So I guess that's what I have to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 18:55:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1399053#M47625</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-13T18:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1400358#M47664</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/104815"&gt;@phatpaul&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I just added support for the LPC804 to the McuFlash module. I quickly tested it with the MinINI (see&amp;nbsp;&lt;A href="https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/" target="_blank"&gt;https://mcuoneclipse.com/2021/12/19/key-value-pairs-in-flash-memory-file-system-less-minini/&lt;/A&gt; ) which uses the flash, you can find the project here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/MCUXpresso/LPC804/LPC804_Blinky" target="_blank"&gt;https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/MCUXpresso/LPC804/LPC804_Blinky&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I did not do much testing, but it seems to work fine.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 15:26:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1400358#M47664</guid>
      <dc:creator>ErichStyger</dc:creator>
      <dc:date>2022-01-17T15:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: LPC804 write flash single word</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1400999#M47675</link>
      <description>&lt;P&gt;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/17173"&gt;@ErichStyger&lt;/a&gt;&amp;nbsp;Thanks so much for all of your example code!&amp;nbsp; (I hope NXP is paying you something to provide the support we need &lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 14:48:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC804-write-flash-single-word/m-p/1400999#M47675</guid>
      <dc:creator>phatpaul</dc:creator>
      <dc:date>2022-01-18T14:48:35Z</dc:date>
    </item>
  </channel>
</rss>

