<?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: Advantages of executing code in RAM in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195067#M5051</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming a&amp;nbsp;Von Neumann setup, if there were to be a speed disparity between between flash memory and (non-zero page) RAM, I might expect there would be either a different number of execution cycles for the same instruction and addressing mode, or a different maximum allowable&amp;nbsp;clock rate.&amp;nbsp; As far as I am aware, neither of these conditions apply to non-banked memory of either persuasion, within&amp;nbsp;Freescale MCUs.&amp;nbsp; Please correct me if I am wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another reason for executing code from RAM would be where temporary code is required, that can be loaded via BDM, SCI, etc.&amp;nbsp;&amp;nbsp;I assume that &amp;nbsp;the P&amp;amp;E method of calibrating the internal reference oscillator uses this method.&amp;nbsp; Any projects that require a factory calibration procedure might benefit from this approach, especially where flash resources are tight.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Jan 2012 22:59:29 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2012-01-06T22:59:29Z</dc:date>
    <item>
      <title>Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195065#M5049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I recently learnt how to load code in RAM an execute it... And I was just wondering... Besides Bootloaders and Flash programming.. What are the advantages of running code from RAM? Or where would you recommend to do so?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2012 01:41:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195065#M5049</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-01-06T01:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195066#M5050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending on your target and other hardware, RAM can be slower or much slower than flash. Executing from RAM your code may exetu faster.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2012 16:22:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195066#M5050</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-01-06T16:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195067#M5051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming a&amp;nbsp;Von Neumann setup, if there were to be a speed disparity between between flash memory and (non-zero page) RAM, I might expect there would be either a different number of execution cycles for the same instruction and addressing mode, or a different maximum allowable&amp;nbsp;clock rate.&amp;nbsp; As far as I am aware, neither of these conditions apply to non-banked memory of either persuasion, within&amp;nbsp;Freescale MCUs.&amp;nbsp; Please correct me if I am wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another reason for executing code from RAM would be where temporary code is required, that can be loaded via BDM, SCI, etc.&amp;nbsp;&amp;nbsp;I assume that &amp;nbsp;the P&amp;amp;E method of calibrating the internal reference oscillator uses this method.&amp;nbsp; Any projects that require a factory calibration procedure might benefit from this approach, especially where flash resources are tight.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jan 2012 22:59:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195067#M5051</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-01-06T22:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195068#M5052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right, there are no obvious reasons to have flash slower than RAM faster and manufacturers are trying to match speeds of&amp;nbsp;flash, RAM and CPU, however with smaller than flash RAM arrays, it is possible to do some performance tricks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- on S12&amp;nbsp;MCU 16bit memory access to word aligned address in flash&amp;nbsp;takes 1 bus cycle, while misaligned word access takes 2 bus cycles. S12 RAM allows both aligned and misaligned write accesses in 1 bus cycle. So in fact RAM is bit faster. This doesn't make feasible to move code to RAM, because&amp;nbsp;S12 instruction queue is there to make code fetched reading aligned words only. And if you have some data in flash, you can align it to make reads faster.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- on&amp;nbsp;S12X MCU operating at 40MHz bus clock, XGATE core (interrupt coprocessor) is able to execute up to 2 instructions per&amp;nbsp;bus cycle when executing from RAM, while it can do only up to 1 instruction per bus cycle when executing from flash. It It is&amp;nbsp;about 2 times faster to execute XGATE code from RAM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding "different number of execution cycles for the same instruction and addressing mode". No, amount of cycles is the same, but some&amp;nbsp;cycles&amp;nbsp;are&amp;nbsp;stretched with waitstates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 03:46:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195068#M5052</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2012-01-07T03:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195069#M5053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used self-modifying code to allow the 68HC05 to download program code into a Xilinx FPGA. The array was of course greater in size than the 8-bit index register could handle. Storing ' LDA AdrHi AdrLow RTS' and calling it, fetched the array data. The data was sent via SPI. Then it was a simple matter to double-precision increment the Adr Low/Hi and check it against the end of the array. In this case it was necessary to use this method to keep the code size small.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 07:25:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195069#M5053</guid>
      <dc:creator>bob_walker</dc:creator>
      <dc:date>2012-01-07T07:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195070#M5054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The technique that you mention was required for HC705 MCUs because&amp;nbsp;of the 8-bit X-register within these devices, and there was no user accessible stack.&amp;nbsp; With a 16-bit index register available&amp;nbsp;within the later device families, this approach would be rarely necessary.&amp;nbsp; I also used a similar method for&amp;nbsp;displaying variable length&amp;nbsp;message string data located in PROM..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For 8-bit devices, with only a single index register,&amp;nbsp;a generalised data transfer routine (in assembler) might slightly benefit in speed, without the need to temporarily store source and destination address indices to the stack.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jan 2012 21:44:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195070#M5054</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2012-01-07T21:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Advantages of executing code in RAM</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195071#M5055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, some interesting points have come here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About the speed, I kind of guess that RAM would be faster than FLASH, but I didn't know it for sure. And I also believe that it depends on the manufacturer and the MCU.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is good to know about the "trick" you mention. Is a nice technique and very useful when dealing with 8-bit pointer register.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for sharing!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2012 20:19:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Advantages-of-executing-code-in-RAM/m-p/195071#M5055</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2012-01-09T20:19:44Z</dc:date>
    </item>
  </channel>
</rss>

