<?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: FLASH update using IAP and __RAMFUNC</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600985#M23352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi Raymundo,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Looking at the address in the disassembly I can see that the function is executed from RAM. I determine that the program is stopped by experiencing that the debugger goes blank and the disassembly returns error. I have also tried to turn on a LED after the call to see if it is something with the debugger, but the LED is not turned on. If I change to any other sector then 0, the function works as expected.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;I have tried to move the interrupt vector as Peter suggested, but still no luck. Do you know if that should be necessary?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Mar 2017 19:57:42 GMT</pubDate>
    <dc:creator>tim99</dc:creator>
    <dc:date>2017-03-02T19:57:42Z</dc:date>
    <item>
      <title>FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600972#M23339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;I am trying to make a routine for updating my firmware without using ISP. So fare I am downloading my firmware to a free location in FLASH and I am now trying to copy this firmware to the first part of the FLASH memory. I am aware that to do this, the function copying the firmware cannot also be in the FLASH section being written to, so I am trying to place this function in RAM using __RAMFUNC. I have attached the code for my function below. However, I am experiencing that the execution is halted after executing the "Erase sectors" IAP command. So it seems to me that the code is not executed from RAM. Anyone have any idea of what I am doing wrong? (I am using LPC1549)&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;__RAMFUNC&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;RAM2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;flashing&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t sectors&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// Command&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// Result&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;typedef&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;IAP&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// IAP Pointer&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;IAP iap_Entry &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IAP&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; IAP_LOCATION&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint8_t ret_code&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint16_t ii&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint8_t data&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1024&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Disable interrupt mode */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;__disable_irq&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Prepare to write/erase the sector */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; IAP_PREWRRITE_CMD&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&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;&lt;SPAN class="comment token"&gt;// strSector&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sectors&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&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; &lt;SPAN class="comment token"&gt;// endSector&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;iap_entry&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;command&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Erase Sectors */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; IAP_ERSSECTOR_CMD&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&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;&lt;SPAN class="comment token"&gt;//strSector;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sectors&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&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; &lt;SPAN class="comment token"&gt;//endSector;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; SystemCoreClock &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;iap_entry&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;command&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;/* Copy 1024 bytes at a time. Sectors = number of sectors to copy */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;i&lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;sectors&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;i&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ii&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; ii&lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1024&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;ii&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&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;&lt;SPAN class="comment token"&gt;/* First read date to RAM before writing to FLASH */&lt;/SPAN&gt;
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;ii&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint8_t&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;START_ADDR_SECTOR&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;i&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1024&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;ii&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Prepare sector for write */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; IAP_PREWRRITE_CMD&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// strSector&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sectors&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;// endSector&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;iap_entry&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;command&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="comment token"&gt;/* Write to FLASH */&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; IAP_WRISECTOR_CMD&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; i&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1024&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uint32_t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;data&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1024&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;command&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; SystemCoreClock &lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1000&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;iap_entry&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;command&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN class="token function"&gt;NVIC_SystemReset&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;//#TODO &lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&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;SPAN&gt;‍&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;/SPAN&gt;&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;SPAN&gt;‍&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;/SPAN&gt;&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;SPAN&gt;‍&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;/SPAN&gt;&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;SPAN&gt;‍&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;/SPAN&gt;&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;SPAN&gt;‍&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;/SPAN&gt;&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;SPAN&gt;‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Feb 2017 19:40:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600972#M23339</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-02-25T19:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600973#M23340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about checking the return code from each IAP call to find out what the error reported?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 08:58:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600973#M23340</guid>
      <dc:creator>converse</dc:creator>
      <dc:date>2017-02-27T08:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600974#M23341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have done that. There are no errors from the IAP calls. I have also tried to run this function and copy the data to&amp;nbsp;free sections of&amp;nbsp;the FLASH memory and that works fine. I therefore do not expect the problem to be the IAP calls, but that my code is not executed from RAM even though I am using __RAMFUNC. But I don't know so any ideas would be highly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 09:59:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600974#M23341</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-02-27T09:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600975#M23342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there Terje,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had/am having a very similar problem thanks to a lack of documentation from NXP. See here&amp;nbsp;&lt;A href="https://community.nxp.com/thread/445475"&gt;IAP via JTAG on LPC1754 #3&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are only having issues programming sector0, like I am, then it might be because you are not relocating the interrupt vector table before writing&amp;nbsp;to that first page.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 17:47:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600975#M23342</guid>
      <dc:creator>petervanhoomiss</dc:creator>
      <dc:date>2017-02-27T17:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600976#M23343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi Peter and thanks for a very interesting tip.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;I was hoping, as I disable interrupts before I erase sector 0, that I would not need to reallocate the interrupt table, but probably I do. I will try this solution as soon as I get back to the office.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Thanks,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Terje&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 18:43:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600976#M23343</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-02-27T18:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600977#M23344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Terje,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just so you know, I just tried my suggestion and it did not work for me. I got to my office a few hours ago.. I am having the exact same problem it seems, if i figure it our I will reply with my fix.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the problem with the erase. I found that sending the REINVOKE ISP command before PREPARE SECTOR and ERASE SECTOR and then performing a reset is necessary for me to be able to write to flash. Might be worth a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best of luck,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 19:19:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600977#M23344</guid>
      <dc:creator>petervanhoomiss</dc:creator>
      <dc:date>2017-02-27T19:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600978#M23345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Thanks for your update Peter. Too bad the solution did not work. I will look into this when I get back to the office on Thursday. Please let me know if you find a solution.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;Terje&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Feb 2017 21:05:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600978#M23345</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-02-27T21:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600979#M23346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-content-finding="Community" data-userid="295100" data-username="tim99" href="https://community.nxp.com/people/tim99"&gt;Terje Mugaas&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.&lt;/P&gt;&lt;P&gt;I think I need the more information about the issue and hope you share.&lt;/P&gt;&lt;P&gt;According to your statement, I think the implementation is the bootloader which allows the the firmware to be downloaded to the targeted flash area, so I'd like to know what flash sectors the bootloader resides in.&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 02:25:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600979#M23346</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2017-02-28T02:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600980#M23347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi Ping,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;Yes, I guess that the function I have added in my first post&amp;nbsp;functions as a bootloader, and as I am using __RAMFUNC I was hoping that the function&amp;nbsp;would reside in RAM.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;I have not made any changes in the memory map so the rest of the application would start&amp;nbsp;from section 0&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2017 12:51:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600980#M23347</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-02-28T12:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600981#M23348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-content-finding="Community" data-objectid="295100" data-objecttype="3" href="https://community.nxp.com/people/tim99"&gt;Terje Mugaas&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thanks for the your reply.&lt;/P&gt;&lt;P&gt;I think you should copy the whole bootloader to the RAM besides the flashing(uint8_t sectors), then program the firmware to the targeted flash area which start from the first flash sector.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 06:47:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600981#M23348</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2017-03-01T06:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600982#M23349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi Ping and thanks for your reply.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;What do you mean by the whole bootloader? I was thinking of my function flashing(uint8_t sectors) as my whole bootloader. Is this function missing something to do the job? There are other parts of my code that is storing the new user code to a free area in the FLASH memory, but I do not understand why that part should also be run from RAM. I would think it would be a benefit not to waste too much RAM on this or is the function only stored in RAM when called? I validate that the downloaded user code is correct and then call flashing(uint8_t sectors) that I was hoping would copy the user code from the free area in FLASH to the first flash sector. I have not yet tried to reallocate the interrupt vector as Peter is mentioning. Can you verify that this must be done even if I have disabled interrupts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Mar 2017 15:01:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600982#M23349</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-03-01T15:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600983#M23350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-content-finding="Community" data-objectid="295100" data-objecttype="3" href="https://community.nxp.com/people/tim99"&gt;Terje Mugaas&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I know the __RAMFUNC execute in the RAM, however the main() function still reside in the Flash.&lt;/P&gt;&lt;P&gt;The correct sequence is the device boots from flash memory and loads the bootloader into RAM. Running from RAM, the&lt;BR /&gt;bootloader has accessed to the entire flash array for placement of the user application. &lt;SPAN style="font-family: TimesLTStd-Roman; font-size: 10pt; color: #000000; font-style: normal; font-variant: normal;"&gt;&lt;BR style="font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" /&gt; &lt;/SPAN&gt;Hope this is clear.&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ping&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 06:08:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600983#M23350</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2017-03-02T06:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600984#M23351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The __RAMFUNC&amp;nbsp; macro should place the function in RAM. You can verify this by looking in the .map file.&lt;/P&gt;&lt;P&gt;I don't believe you need to place other code In RAM since the function does not return.&lt;/P&gt;&lt;P&gt;You say that it stops executing after the IAP "Erase Sectors" command.&amp;nbsp; How did you determine this?&lt;/P&gt;&lt;P&gt;The next thing you do after erasing flash is to copy 1024 bytes into the data array. I don't know how your system is configured, but if the stack is also placed in RAM2,&amp;nbsp;what could be happening is that, since the data array is placed in the stack it could overflow into your function and when you copy from flash&amp;nbsp;into the array you overwrite some of the function.&lt;/P&gt;&lt;P&gt;You can try one of&amp;nbsp;the following.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Make sure that the stack is in not in RAM2 area.&lt;/LI&gt;&lt;LI&gt;Allocate the data array as a global variable in a different RAM area.&lt;/LI&gt;&lt;LI&gt;Change the array size and copy only a few bytes at a time just to see if this is the case.&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 19:27:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600984#M23351</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-03-02T19:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600985#M23352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Hi Raymundo,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Looking at the address in the disassembly I can see that the function is executed from RAM. I determine that the program is stopped by experiencing that the debugger goes blank and the disassembly returns error. I have also tried to turn on a LED after the call to see if it is something with the debugger, but the LED is not turned on. If I change to any other sector then 0, the function works as expected.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;I have tried to move the interrupt vector as Peter suggested, but still no luck. Do you know if that should be necessary?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 19:57:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600985#M23352</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-03-02T19:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600986#M23353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Terje,&lt;/P&gt;&lt;P&gt;What I meant is not "how do you determine the program is stopped?"&lt;/P&gt;&lt;P&gt;How do you determine the last code that was executed?&lt;/P&gt;&lt;P&gt;Are you running the debugger one instruction at a time and it never returns from _iap_entry "erase sectors" command?&lt;/P&gt;&lt;P&gt;In other words, are you sure it never entered the loop to copy the 1024 bytes to data array?&lt;/P&gt;&lt;P&gt;You can create and place in RAM the following:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;NMI_Handler, &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// The NMI handler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; HardFault_Handler, &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// The hard fault handler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; MemManage_Handler, &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// The MPU fault handler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; BusFault_Handler, &lt;/SPAN&gt;&lt;SPAN style="color: #3f7f5f; font-size: small;"&gt;// The bus fault handler&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;UsageFault_Handler,&lt;/P&gt;&lt;P&gt;Just have them stay in an infinite loop. Then you can determine if any of these exceptions occurred.&lt;/P&gt;&lt;P&gt;And yes, moving the vector table to RAM is a good idea. You need to do it anyway for this test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:32:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600986#M23353</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-03-02T20:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600987#M23354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can a similar result be achieved by disabling interrupts before the IAP call untill after the IAP function? Using the "CPS" thumb instruction to set the PRIMASK and FAULT mask should disable any exception (except NMI) from being triggered. I believe this is the underling behavior of the __disable_irq(); and __enable_irq(); functions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:45:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600987#M23354</guid>
      <dc:creator>petervanhoomiss</dc:creator>
      <dc:date>2017-03-02T20:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600988#M23355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, I missed the first time I read your reply that it works when you don't try writing to sector 0.&lt;/P&gt;&lt;P&gt;You don't mention if you are using an OS, but if you are, you need to shut it down before attempting to update your program. The OS will use the SVC_Handler and PendSV_Handler which are in flash.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:45:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600988#M23355</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-03-02T20:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600989#M23356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Exceptions are not interrupts and&amp;nbsp;occur regardless of the interrupt enable status.&amp;nbsp;Which exception occurs could give you a clue as to what could be going wrong or needs to be done differently.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:57:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600989#M23356</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-03-02T20:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600990#M23357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;Finally, I managed to get it working. Thank you all for guiding me to the solution.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 8pt;"&gt;I found that you don't have to move the vector table, but doing so helped me to find out what was wrong. I moved the vector table by copying the first sector to the last sector and then changed VTOR. I then found that my program ended up in the Hard Fault handler. Before moving the vector table the pointer to the Hard Fault handle would have been erased, but now I could investigate what had happened by looking at the vectpc register. I found that my program counter had tried to execute a line in sector 0 that I had erased. The guilty function was iap_entry. I found that the program was calling iap_entry in romapi_15xx.h and not iap_Entry that I had declared. I was not aware that there existed a function with almost the same name as I had used. This function was of course erased when I erased the sector and hence the error. Changing the name of my declaration in RAM and updating the function calls to the new name solved my problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Mar 2017 12:27:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600990#M23357</guid>
      <dc:creator>tim99</dc:creator>
      <dc:date>2017-03-03T12:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: FLASH update using IAP and __RAMFUNC</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600991#M23358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good to hear you solved it.&lt;/P&gt;&lt;P&gt;We all missed that you declared "iap_Entry" but called "iap_entry"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Mar 2017 14:02:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/FLASH-update-using-IAP-and-RAMFUNC/m-p/600991#M23358</guid>
      <dc:creator>Ray_V</dc:creator>
      <dc:date>2017-03-03T14:02:42Z</dc:date>
    </item>
  </channel>
</rss>

