<?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: Copy FLASH to RAM and running the code from RAM</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153061#M293</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's one method for calling the Flash routine from RAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// This routine runs from SRAM - the reason why the pointer is passed is to avoid the routine taking it from a const value in FLASH, which is then not code location dependent//static void fnFlashRoutine(volatile unsigned char *ptrFTFL_BLOCK){    *ptrFTFL_BLOCK = FTFL_STAT_CCIF;                                 // launch the command - this clears the FTFL_STAT_CCIF flag (register is FTFL_FSTAT)    while (!(*ptrFTFL_BLOCK &amp;amp; FTFL_STAT_CCIF)) {}                    // wait for the command to terminate}static void fnConfigFlashRam(void){    static void (*fnRAM_code)(volatile unsigned char *) = 0;    #define PROG_WORD_SIZE 30                                        // adequate space for the small program    int i = 0;    unsigned char *ptrThumb2 = (unsigned char *)fnFlashRoutine;    static unsigned short usProgSpace[PROG_WORD_SIZE];               // make space for the routine on stack (this will have an even boundary)    ptrThumb2 =  (unsigned char *)(((CAST_POINTER_ARITHMETIC)ptrThumb2) &amp;amp; ~0x1); // thumb 2 address    while (i &amp;lt; PROG_WORD_SIZE) {                                     // copy program to SRAM        usProgSpace[i++] = *(unsigned short *)ptrThumb2;        ptrThumb2 += sizeof (unsigned short);    }    ptrThumb2 = (unsigned char *)usProgSpace;    ptrThumb2++;                                                     // create a thumb 2 call    fnRAM_code = (void(*)(volatile unsigned char *))(ptrThumb2);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call fnFlashRoutine() using;&lt;BR /&gt;&lt;BR /&gt;fnRAM_code((volatile unsigned char *)FTFL_BLOCK);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // execute the command from SRAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also block interrupts when the routine is called if interrupt handlers are in FLASH.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 08:56:32 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2020-10-29T08:56:32Z</dc:date>
    <item>
      <title>Copy FLASH to RAM and running the code from RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153060#M292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using CW10.1 and K10.&lt;/P&gt;&lt;P&gt;Apparently I can't write or erase sectors from the same block that my code is running from (different sectors from the sectors where the code exist of course)&lt;/P&gt;&lt;P&gt;I want to copy a portion of my code from flash to RAM and run sections of the code from RAM and other part of the code from FLASH.&lt;/P&gt;&lt;P&gt;How can I do that ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Jul 2011 01:21:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153060#M292</guid>
      <dc:creator>kinetis_user</dc:creator>
      <dc:date>2011-07-23T01:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Copy FLASH to RAM and running the code from RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153061#M293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's one method for calling the Flash routine from RAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// This routine runs from SRAM - the reason why the pointer is passed is to avoid the routine taking it from a const value in FLASH, which is then not code location dependent//static void fnFlashRoutine(volatile unsigned char *ptrFTFL_BLOCK){    *ptrFTFL_BLOCK = FTFL_STAT_CCIF;                                 // launch the command - this clears the FTFL_STAT_CCIF flag (register is FTFL_FSTAT)    while (!(*ptrFTFL_BLOCK &amp;amp; FTFL_STAT_CCIF)) {}                    // wait for the command to terminate}static void fnConfigFlashRam(void){    static void (*fnRAM_code)(volatile unsigned char *) = 0;    #define PROG_WORD_SIZE 30                                        // adequate space for the small program    int i = 0;    unsigned char *ptrThumb2 = (unsigned char *)fnFlashRoutine;    static unsigned short usProgSpace[PROG_WORD_SIZE];               // make space for the routine on stack (this will have an even boundary)    ptrThumb2 =  (unsigned char *)(((CAST_POINTER_ARITHMETIC)ptrThumb2) &amp;amp; ~0x1); // thumb 2 address    while (i &amp;lt; PROG_WORD_SIZE) {                                     // copy program to SRAM        usProgSpace[i++] = *(unsigned short *)ptrThumb2;        ptrThumb2 += sizeof (unsigned short);    }    ptrThumb2 = (unsigned char *)usProgSpace;    ptrThumb2++;                                                     // create a thumb 2 call    fnRAM_code = (void(*)(volatile unsigned char *))(ptrThumb2);}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;call fnFlashRoutine() using;&lt;BR /&gt;&lt;BR /&gt;fnRAM_code((volatile unsigned char *)FTFL_BLOCK);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // execute the command from SRAM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also block interrupts when the routine is called if interrupt handlers are in FLASH.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:56:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153061#M293</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2020-10-29T08:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Copy FLASH to RAM and running the code from RAM</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153062#M294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Tried it and it works perfect for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 02:27:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Copy-FLASH-to-RAM-and-running-the-code-from-RAM/m-p/153062#M294</guid>
      <dc:creator>kinetis_user</dc:creator>
      <dc:date>2011-07-26T02:27:28Z</dc:date>
    </item>
  </channel>
</rss>

