<?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: Programming Flash from which the program was booted, LPC43xx (LPC-Link2) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821370#M32869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dmitry Kuklin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand the following statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;While&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;LPCOpen&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;SPIFI example&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;tries to use fast read quad I/O with "continuous read mode" (see W25Q80BV manual), which is much faster.&amp;nbsp;But it doesn't work in my case.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you give me more information about "does not work my case" mean, Did you edit the example? or how do you know that does not work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;BR /&gt;Miguel Mendoza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Aug 2018 15:59:43 GMT</pubDate>
    <dc:creator>miguel_mendoza</dc:creator>
    <dc:date>2018-08-08T15:59:43Z</dc:date>
    <item>
      <title>Programming Flash from which the program was booted, LPC43xx (LPC-Link2)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821369#M32868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to program Flash memory from the running program (the Flash is 1MB W25Q80BV on LPC-Link2, LPC4370 chip). I'm using SPIFI example from LPCOpen 3.02 for LPCXpresso. This example is currently located in directory "misc_spifi_tst", (&lt;A class="link-titled" href="https://www.nxp.com/downloads/en/libraries/lpcopen_3_02_lpcxpresso_link2_4370.zip" title="https://www.nxp.com/downloads/en/libraries/lpcopen_3_02_lpcxpresso_link2_4370.zip"&gt;https://www.nxp.com/downloads/en/libraries/lpcopen_3_02_lpcxpresso_link2_4370.zip&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;After some&amp;nbsp;tweaking with placing functions in RAM (to program the flash from which the program was booted), I successfully&amp;nbsp;wrote data to Flash (that part of the Flash which was not occupied by the code). However,&amp;nbsp;I have problems when switching back to execution code from the Flash.&lt;/P&gt;&lt;P&gt;Here is the approximate&amp;nbsp;sequence:&lt;/P&gt;&lt;P&gt;1. Entering command mode;&lt;/P&gt;&lt;P&gt;2. Writing data to Flash;&lt;/P&gt;&lt;P&gt;3. Entering memory mode;&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Executing code, located in Flash. The problem&amp;nbsp;starts here. It seems that it can't read the&amp;nbsp;code. Looks like the chip doesn't recognize the Flash (for code execution). So calling&amp;nbsp;any function located in Flash drives microcontroller crazy. Maybe it didn't enter&amp;nbsp;&lt;SPAN&gt;memory mode properly. So, maybe I need to do something else&amp;nbsp;to enter the&amp;nbsp;&lt;SPAN&gt;memory mode and&amp;nbsp;the chip could see the code in Flash (as it was before switching to&amp;nbsp;&lt;SPAN&gt;command mode&lt;/SPAN&gt;)?&amp;nbsp;Core reset helps to go back to&amp;nbsp;e&lt;SPAN&gt;xecution code from Flash but it is not very convenient (resetting after each Flash programming).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;Maybe it is the same problem&amp;nbsp;as this one&amp;nbsp;&lt;A href="https://community.nxp.com/thread/422315"&gt;SPIFI Command Mode to Memory Mode&lt;/A&gt;? Seems like in the&amp;nbsp;LPCOpen&amp;nbsp;&lt;SPAN&gt;SPIFI example a similar approach is used to that in the link (and in the example, they also mention Spansion memory; in the link - Spansion S25FL256S is used). But in my case, it is different Flash memory and I need a different code/settings to switch correctly to&amp;nbsp;&lt;SPAN&gt;memory mode?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;Edit: I got it working. What I did is simply read all the needed registers before entering&lt;SPAN&gt;&amp;nbsp;command mode (CTRL,&amp;nbsp;CMD, IDATA, and MCMD) and loaded them to enter memory mode. Btw, the chip uses very inefficient&amp;nbsp;serial mode! While&amp;nbsp;&lt;SPAN&gt;LPCOpen&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;SPIFI example&lt;SPAN&gt;&amp;nbsp;tries to use fast read quad I/O with "continuous read mode" (see W25Q80BV manual), which is much faster.&amp;nbsp;But it doesn't work in my case. So maybe someone could successfully&amp;nbsp;use the fast mode?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2018 19:23:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821369#M32868</guid>
      <dc:creator>kuklindima</dc:creator>
      <dc:date>2018-08-04T19:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash from which the program was booted, LPC43xx (LPC-Link2)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821370#M32869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dmitry Kuklin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not understand the following statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;While&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;LPCOpen&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;SPIFI example&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;tries to use fast read quad I/O with "continuous read mode" (see W25Q80BV manual), which is much faster.&amp;nbsp;But it doesn't work in my case.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you give me more information about "does not work my case" mean, Did you edit the example? or how do you know that does not work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;BR /&gt;Miguel Mendoza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2018 15:59:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821370#M32869</guid>
      <dc:creator>miguel_mendoza</dc:creator>
      <dc:date>2018-08-08T15:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash from which the program was booted, LPC43xx (LPC-Link2)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821371#M32870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, I placed critical functions in RAM. And then I tried&amp;nbsp;to change&amp;nbsp;spifi_memory_mode() function, as the original one didn't switch to memory mode correctly.&lt;/P&gt;&lt;P&gt;The microcontroller doesn't "see" code, located in the flash: it cannot read data if it is located in flash (if I try to access some array, for example) and it hangs when it tries to&amp;nbsp;call some function in flash.&lt;/P&gt;&lt;P&gt;When I enter memory mode correctly, everything works fine. But I only could&amp;nbsp;&lt;SPAN&gt;switch to memory mode using serial mode. Currently, the&amp;nbsp;&lt;SPAN&gt;spifi_memory_mode()&amp;nbsp;&lt;/SPAN&gt;looks like this (I simply loaded the values of the registers that I read before entering command mode):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;__RAMFUNC(RAM) void spifi_memory_mode(void) {&lt;BR /&gt;#ifdef CORE_M4 &lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;SCnSCB-&amp;gt;ACTLR &amp;amp;= ~2;&lt;BR /&gt;#endif&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;LPC_SPIFI-&amp;gt;CTRL = 0x6009ffff;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;LPC_SPIFI-&amp;gt;DATINTM = 0xffffffff;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;LPC_SPIFI-&amp;gt;CMD = 0x3800000;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;while(LPC_SPIFI-&amp;gt;STAT &amp;amp; 2);&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;LPC_SPIFI-&amp;gt;MEMCMD = 0x3800000;&lt;BR /&gt;#ifdef CORE_M4&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;SCnSCB-&amp;gt;ACTLR |= 2;&lt;BR /&gt;#endif&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It works but this is serial mode. It would be better to use one of the fast modes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It is also interesting to know when the values of the registers were set initially (i.e. at which stage of boot/initialization process this memory mode was chosen and set); can it be altered right there, or the only way to change memory mode is reinitialization.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2018 20:08:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821371#M32870</guid>
      <dc:creator>kuklindima</dc:creator>
      <dc:date>2018-08-08T20:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash from which the program was booted, LPC43xx (LPC-Link2)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821372#M32871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Dmitry Kuklin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We share you via email an example for LPC4370, made by the team, that uses the SPIFI library that we provide. I think that can cover that you need. the example has some functions to entry to memory mode (also in fast mode) in a simple way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopes it helps! and if you have any questions or problems let me know through this thread&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;BR /&gt;Miguel Mendoza&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Aug 2018 18:57:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821372#M32871</guid>
      <dc:creator>miguel_mendoza</dc:creator>
      <dc:date>2018-08-09T18:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Programming Flash from which the program was booted, LPC43xx (LPC-Link2)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821373#M32872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks,&amp;nbsp;Miguel! I'll dig into it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Aug 2018 01:05:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Programming-Flash-from-which-the-program-was-booted-LPC43xx-LPC/m-p/821373#M32872</guid>
      <dc:creator>kuklindima</dc:creator>
      <dc:date>2018-08-10T01:05:18Z</dc:date>
    </item>
  </channel>
</rss>

