<?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: SPIFI Command Mode to Memory Mode</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPIFI-Command-Mode-to-Memory-Mode/m-p/582157#M20605</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ArriaLive on Fri Aug 29 13:02:16 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I will answer my own question.&amp;nbsp; I kept working at this until I figured out what was going on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The flash memory was not disappearing, it was just having access trouble.&amp;nbsp; It turns out that you can't simply "put the system back in memory mode" setting the registers as they were--at least not if you're using "no opcode" high-performance mode.&amp;nbsp; For high-performance mode, here are the steps I used (this example uses a Spansion part).&amp;nbsp; Note that this is different than the examples in the SPIFI library!:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Set the intermediate code to 0xA5.&amp;nbsp; During the actual memory read command (coming up next), this intermediate code tells the flash memory that the *next* request will not be sending an opcode, just the address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Send one "real" memory request using the CMD register, with the desired opcode.&amp;nbsp; The frameform must use the opcode-with-address (either 3 or 4 byte) option, and the ADDR register needs to be set to something.&amp;nbsp; Zero is fine.&amp;nbsp; DATALEN should also be 0.&amp;nbsp; This CMD makes the initial memory request using the opcode, then sends the intermediate code telling the flash memory what to expect with the *next* request.&amp;nbsp; This is the key--get that intermediate code registered with the flash so that subsequent requests are address-only (saving 8 clock cycles per request).&amp;nbsp; Also, make sure to monitor the STAT register to make sure this CMD has completed prior to going on to the next step.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Send the MEMCMD the actual code you want the memory to use in memory mode.&amp;nbsp; The opcode should be the same as you sent in #2 above, but the frameform must be the no-opcode-with-address flag (either 3 or 4 byte addressing).&amp;nbsp; The intermediate data should always remain 0xA5 to tell the flash memory (again) that the next request will not use an opcode again.&amp;nbsp; This MEMCMD puts the SPIFI in memory mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When doing this (and getting the CTRL register set up correctly), I have successfully gotten back in to high-performance memory mode with all addresses in memory looking correct, with XIP working as well.&amp;nbsp; Note that I used the Spansion "EC" opcode for 4-byte addressing and quad-speed addressing, intermediate, and data communications.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps others to understand some of the complexity of SPIFI setup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EdA&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:22:08 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:22:08Z</dc:date>
    <item>
      <title>SPIFI Command Mode to Memory Mode</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPIFI-Command-Mode-to-Memory-Mode/m-p/582156#M20604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ArriaLive on Wed Aug 27 01:06:38 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I discovered last week that when I ran XIP code over SPIFI during a debug session, I could pretty much get full quad mode at 104MHz.&amp;nbsp; But outside of the debugger, SPIFI was running far slower--in SDR mode, and 50MHz was the max I could squeeze out of it.&amp;nbsp; Performance dropped from 52MB/s to 6MB/s.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I discovered that this was because the debugger puts the flash in quad mode, but without the debugger, my code was not putting it in quad high-performance mode.&amp;nbsp; Makes sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I've spent the last week trying to get the flash into high performance mode, but I continue to fail at that effort.&amp;nbsp; The problem is that when I put the SPIFI interface into memory mode, the memory essentially disappears.&amp;nbsp; Here's an example of a simple routine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Memory at 0x14000000 at start of routine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000000 - 10020000 140004FD 1400018D 14000191 14000195 14000199 1400019D 00000000 00000000 00000000&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000028 - 00000000 140001A1 140001A5 00000000 140001A9 14009C25 140001B1 140001B1 10000079 00000000&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000050 - 140001B1 1000011D 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000078 - 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 140001B1 &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clearly showing what appears to be a vector table.&amp;nbsp; Then I execute the following sequence simply going from memory mode to command mode and back again:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; __disable_irq(); // Disable IRQs&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCnSCB-&amp;gt;ACTLR &amp;amp;= ~2; // disable Cortex write buffer to avoid exceptions when switching back to SPIFI for execution&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tempmemcmd = LPC_SPIFI-&amp;gt;MEMCMD;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* check for memory mode.&amp;nbsp; If not there, reset */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (LPC_SPIFI-&amp;gt;STAT &amp;amp; SPIFI_STAT_MCINIT) { // In memory mode? MCINIT bit is bit 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SPIFI-&amp;gt;STAT = SPIFI_STAT_RESET; // Go to command mode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(LPC_SPIFI-&amp;gt;STAT &amp;amp; SPIFI_STAT_RESET); // wait for reset to complete&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_SPIFI-&amp;gt;MEMCMD = tempmemcmd;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the end, all 8 SPIFI registers look EXACTLY as they did at the beginning.&amp;nbsp; After the reset, the MCINIT bit is 0 as expected.&amp;nbsp; After the MEMCMD, the MCINIT bit goes to 1 as expected.&amp;nbsp; All the registers look right, but the memory itself does not.&amp;nbsp; Here's what that same segment of flash memory looks like at the end of that short sequence:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000000 - 00000000 00000000 CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000028 - CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000050 - CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0x14000078 - CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Obviously something is wrong.&amp;nbsp; All the flash data is essentially gone.&amp;nbsp; Any attempt to XIP anywhere in flash after this, of course, creates a hard-fault exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I must be missing something somewhere.&amp;nbsp; Why is the flash going away?&amp;nbsp; Am I missing a register setting or some other requirement?&amp;nbsp; I've scoured the documentation for both the processor and flash.&amp;nbsp; I've searched the forums and googled everything I could think of.&amp;nbsp; But I have not found an answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone have any ideas?&amp;nbsp; Thank you in advance for the guidance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Processor: LPC4330&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Flash:&amp;nbsp; Spansion S25FL256S&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EdA&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:22:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPIFI-Command-Mode-to-Memory-Mode/m-p/582156#M20604</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: SPIFI Command Mode to Memory Mode</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/SPIFI-Command-Mode-to-Memory-Mode/m-p/582157#M20605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by ArriaLive on Fri Aug 29 13:02:16 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I will answer my own question.&amp;nbsp; I kept working at this until I figured out what was going on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The flash memory was not disappearing, it was just having access trouble.&amp;nbsp; It turns out that you can't simply "put the system back in memory mode" setting the registers as they were--at least not if you're using "no opcode" high-performance mode.&amp;nbsp; For high-performance mode, here are the steps I used (this example uses a Spansion part).&amp;nbsp; Note that this is different than the examples in the SPIFI library!:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Set the intermediate code to 0xA5.&amp;nbsp; During the actual memory read command (coming up next), this intermediate code tells the flash memory that the *next* request will not be sending an opcode, just the address.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Send one "real" memory request using the CMD register, with the desired opcode.&amp;nbsp; The frameform must use the opcode-with-address (either 3 or 4 byte) option, and the ADDR register needs to be set to something.&amp;nbsp; Zero is fine.&amp;nbsp; DATALEN should also be 0.&amp;nbsp; This CMD makes the initial memory request using the opcode, then sends the intermediate code telling the flash memory what to expect with the *next* request.&amp;nbsp; This is the key--get that intermediate code registered with the flash so that subsequent requests are address-only (saving 8 clock cycles per request).&amp;nbsp; Also, make sure to monitor the STAT register to make sure this CMD has completed prior to going on to the next step.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Send the MEMCMD the actual code you want the memory to use in memory mode.&amp;nbsp; The opcode should be the same as you sent in #2 above, but the frameform must be the no-opcode-with-address flag (either 3 or 4 byte addressing).&amp;nbsp; The intermediate data should always remain 0xA5 to tell the flash memory (again) that the next request will not use an opcode again.&amp;nbsp; This MEMCMD puts the SPIFI in memory mode.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When doing this (and getting the CTRL register set up correctly), I have successfully gotten back in to high-performance memory mode with all addresses in memory looking correct, with XIP working as well.&amp;nbsp; Note that I used the Spansion "EC" opcode for 4-byte addressing and quad-speed addressing, intermediate, and data communications.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps others to understand some of the complexity of SPIFI setup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EdA&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:22:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/SPIFI-Command-Mode-to-Memory-Mode/m-p/582157#M20605</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:22:08Z</dc:date>
    </item>
  </channel>
</rss>

