<?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>ColdFire/68K Microcontrollers and ProcessorsのトピックRe: Copy function to stack</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Copy-function-to-stack/m-p/124574#M124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You only need to copy the code that does the actual programming or erase. For example:&lt;BR /&gt;&lt;BR /&gt; #define IPSFLASH(x) (*(long *)(0x44000000 + (x)))&lt;BR /&gt; int&lt;BR /&gt; runInRam(char cmd, long *addr, long val) {&lt;BR /&gt; CFMSTAT = PVIOL | ACCERR;&lt;BR /&gt; IPSFLASH(addr) = val;&lt;BR /&gt; CFMCMD = cmd;&lt;BR /&gt; CFMSTAT = CBEIF;&lt;BR /&gt; while (!(CFMSTAT &amp;amp; (CCIF | PVIOL | ACCERR)));&lt;BR /&gt; return CFMSTAT &amp;amp; (PVIOL | ACCERR);&lt;BR /&gt; }&lt;BR /&gt; void runEnd(void){} // leave this immediately after runInRam&lt;BR /&gt;&lt;BR /&gt;The function to program an array of longs, for instance:&lt;BR /&gt;&lt;BR /&gt; int&lt;BR /&gt; flashProg(long *dest, long *src, int n) {&lt;BR /&gt; char buf[120];&lt;BR /&gt; int (*ramCopy)(char,long*,long) = (int(*)(char,long*,long))buf;&lt;BR /&gt; memcpy(buf, (void*)runInRam, (char*)runEnd - (char*)runInRam);&lt;BR /&gt; while (n--) {&lt;BR /&gt; if (ramCopy(CMDPROG, dest++, *src++)) return -1;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;You could also copy 'runInRam' to a static buffer just large enough (chech the map file) during initialization.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Jul 2006 01:21:08 GMT</pubDate>
    <dc:creator>mvincent</dc:creator>
    <dc:date>2006-07-21T01:21:08Z</dc:date>
    <item>
      <title>Copy function to stack</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Copy-function-to-stack/m-p/124573#M123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Does someone has an example code how to load function to stack and run it there (i need it to program/erase flash)?&lt;/DIV&gt;&lt;DIV&gt;Do i need to run from the memory only the command to the flash or more (in the program command flow)?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 15:01:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Copy-function-to-stack/m-p/124573#M123</guid>
      <dc:creator>UDP</dc:creator>
      <dc:date>2006-07-20T15:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Copy function to stack</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Copy-function-to-stack/m-p/124574#M124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You only need to copy the code that does the actual programming or erase. For example:&lt;BR /&gt;&lt;BR /&gt; #define IPSFLASH(x) (*(long *)(0x44000000 + (x)))&lt;BR /&gt; int&lt;BR /&gt; runInRam(char cmd, long *addr, long val) {&lt;BR /&gt; CFMSTAT = PVIOL | ACCERR;&lt;BR /&gt; IPSFLASH(addr) = val;&lt;BR /&gt; CFMCMD = cmd;&lt;BR /&gt; CFMSTAT = CBEIF;&lt;BR /&gt; while (!(CFMSTAT &amp;amp; (CCIF | PVIOL | ACCERR)));&lt;BR /&gt; return CFMSTAT &amp;amp; (PVIOL | ACCERR);&lt;BR /&gt; }&lt;BR /&gt; void runEnd(void){} // leave this immediately after runInRam&lt;BR /&gt;&lt;BR /&gt;The function to program an array of longs, for instance:&lt;BR /&gt;&lt;BR /&gt; int&lt;BR /&gt; flashProg(long *dest, long *src, int n) {&lt;BR /&gt; char buf[120];&lt;BR /&gt; int (*ramCopy)(char,long*,long) = (int(*)(char,long*,long))buf;&lt;BR /&gt; memcpy(buf, (void*)runInRam, (char*)runEnd - (char*)runInRam);&lt;BR /&gt; while (n--) {&lt;BR /&gt; if (ramCopy(CMDPROG, dest++, *src++)) return -1;&lt;BR /&gt; }&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;You could also copy 'runInRam' to a static buffer just large enough (chech the map file) during initialization.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 01:21:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/Copy-function-to-stack/m-p/124574#M124</guid>
      <dc:creator>mvincent</dc:creator>
      <dc:date>2006-07-21T01:21:08Z</dc:date>
    </item>
  </channel>
</rss>

