<?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: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525603#M8239</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Tue Aug 05 09:25:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how to tell if I get a fault because it only happens after I stop the debugging process - after I reboot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hence the vague term 'crashes'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:54:57 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:54:57Z</dc:date>
    <item>
      <title>In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525601#M8237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Mon Aug 04 18:31:10 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to use IAP to store a variable in NV Flash RAM that will retain its state after reboot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using my own linker script and storing the variable at location 0x6000 far away from anything else.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This the memory is being properly written to when I initially debug the application, but not after reboot.&amp;nbsp; After rebooting, the code crashes when I try to erase the iap sector before writing to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is the relevant portion of my iap code:&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;int iap_erase_sector(unsigned int sector_start, unsigned int sector_end)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int command[5];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int result[4];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[0] = ERASE_SECTOR; // 52&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[1] = (unsigned int)sector_start;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[2] = (unsigned int)sector_end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[3] = SystemCoreClock / 1000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_entry(command, result);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result[0];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int iap_prepare_sector(unsigned int sector_start, unsigned int sector_end)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int command[5];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int result[4];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[0] = PREPARE_SECTOR; // 50&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[1] = (unsigned int) sector_start;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[2] = (unsigned int) sector_end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_entry(command, result);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result[0];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int iap_copy_ram_to_flash(void* ram_address, void* flash_address, unsigned int count)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int command[5];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int result[4];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[0] = COPY_RAM_TO_FLASH; // 51&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[1] = (unsigned int)flash_address;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[2] = (unsigned int)ram_address;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[3] = count;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; command[4] = SystemCoreClock / 1000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_entry(command, result);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return result[0];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int iap_write(void *ram_address, void *flash_address, unsigned int count, unsigned int sector, unsigned int sector_size)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; int iap_status = 0; // CMD_SUCCESS&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SystemCoreClockUpdate();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_status = iap_prepare_sector(sector, sector_size);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (iap_status != 0) return iap_status;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // after reboot, this crashes when I try to erase the sector&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_status = iap_erase_sector(sector, sector_size);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (iap_status != 0) return iap_status;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_status = iap_prepare_sector(sector, sector_size);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (iap_status != 0) return iap_status;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; iap_status = iap_copy_ram_to_flash(ram_address, flash_address, count);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (iap_status != 0) return iap_status;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return iap_status;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is the relevant section of my linker script:&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .var (0x6000) :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KEEP(*(.var*))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;gt; MFlash32&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is the relevant section of my calling code:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__CRP const unsigned int CRP_WORD = CRP_NO_CRP;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;static unsigned char var_temp[] = {0, 1, 1, 1, 1, 1, 1, 1, 1};&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;__attribute__ ((section(".var"))) unsigned char var[256];&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;int main()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC_SYSCON-&amp;gt;SYSAHBCLKCTRL |= (1 &amp;lt;&amp;lt; 16);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if (var[0] == 0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&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; // after reboot, this crashes when I try to erase the sector&lt;/SPAN&gt;&lt;BR /&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; // iap_write(ram_address, flash_address, count, sector, sector_size)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;iap_write(&amp;amp;var_temp, (void *)0x6000, 256, 6, 7);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while (1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;return 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525601#M8237</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525602#M8238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Tue Aug 05 01:01:34 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;What do you mean by 'crashes'? Do you get a fault? If you want help, please describe what actually happens rather than using vague terms.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525602#M8238</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525603#M8239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Tue Aug 05 09:25:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how to tell if I get a fault because it only happens after I stop the debugging process - after I reboot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hence the vague term 'crashes'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525603#M8239</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525604#M8240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Tue Aug 05 09:31:44 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The program goes into an unexpected state after reboot if I erase the sector.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I try communicating with the MCU over UART after reboot, but this fails.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to communicate with the MCU over UART after reboot if I comment out the erase sector function in the iap write command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please let me know what other information I can provide.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525604#M8240</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525605#M8241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Wed Aug 06 17:25:09 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas as to why this would only work when I first debug, and not after I reboot and stop debugging?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any more relevant information I can provide?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525605#M8241</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525606#M8242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Wed Aug 06 21:42:01 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;This may be an issue with my UART interrupt handler.&amp;nbsp; I've tried disabling and re-enabling before and after writing to flash, but to no avail.&amp;nbsp; Can anyone recommend how to properly disable and re-enable my interrupt?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is what I am currently doing:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; NVIC_DisableIRQ(UART_IRQn);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;iap_write(&amp;amp;var_temp, (void *)0x6000, 256, 6, 7);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; NVIC_EnableIRQ(UART_IRQn);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:54:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525606#M8242</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525607#M8243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Wed Aug 06 23:42:07 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;RAM problems?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fcontent%2Ffaq%2Flpcxpresso%2Freserving-ram-iap" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/content/faq/lpcxpresso/reserving-ram-iap&lt;/A&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525607#M8243</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525608#M8244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Thu Aug 07 11:53:50 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi LabRat,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your suggestion.&amp;nbsp; I have moved the stack offset to reserve space for the IAP command set using my linker script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MEMORY&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; /* Define each memory region */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32k */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8k */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; /* Define a symbol for the top of each memory region */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; __top_MFlash32 = 0x0 + 0x8000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; __top_RamLoc8 = 0x10000000 + 0x2000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;_vRamTop = __top_RamLoc8 ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;_vStackTop = _vRamTop - 32; /* offset 32 for iap command set */&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to be an issue with the UART line status not firing (i.e. LPC_UART-&amp;gt;LSR is never getting set.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've taken out the UART interrupt and instead I just poll the line status (I know - not the best asynchronous design, but for debugging...), but it is not getting setting when I send a UART command after reboot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As before, the UART commands go through after reboot when I comment out the erase sector portion of the iap write.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525608#M8244</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525609#M8245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Thu Aug 07 13:53:13 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: mroe&lt;/STRONG&gt;&lt;BR /&gt; Can anyone recommend how to properly disable and re-enable my interrupt?&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here is what I am currently doing:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; NVIC_DisableIRQ(UART_IRQn);&lt;BR /&gt;iap_write(&amp;amp;var_temp, (void *)0x6000, 256, 6, 7);&lt;BR /&gt;&amp;nbsp; NVIC_EnableIRQ(UART_IRQn);&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would suggest to use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
 __disable_irq();
...iap_
 __enable_irq();
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525609#M8245</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525610#M8246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Thu Aug 07 14:21:32 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yeah, tried the global disable and re-enable interrupt but to no avail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I even took the interrupt handler out of my code completely, and instead I just poll the line status register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // this condition is never evaluates to true after reboot if i've erased the sector when first debugging the application&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// however, this condition does fire if I haven't erased the sector when first debugging&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (LPC_UART-&amp;gt;LSR &amp;amp; 0x01)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;// read from uart FIFO&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525610#M8246</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525611#M8247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Thu Aug 07 14:49:33 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure which ISR we are talking about...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you using a sample ISR? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;/*****************************************************************************
** Function name:UART_IRQHandler
**
** Descriptions:UART interrupt handler
**
** parameters:None
** Returned value:None
** 
*****************************************************************************/
void UART_IRQHandler(void)
{
&amp;nbsp; uint8_t IIRValue, LSRValue;
&amp;nbsp; uint8_t Dummy = Dummy;

&amp;nbsp; IIRValue = LPC_UART-&amp;gt;IIR;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp; IIRValue &amp;gt;&amp;gt;= 1;/* skip pending bit in IIR */
&amp;nbsp; IIRValue &amp;amp;= 0x07;/* check bit 1~3, interrupt identification */
&amp;nbsp; if (IIRValue == IIR_RLS)/* Receive Line Status */
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; LSRValue = LPC_UART-&amp;gt;LSR;
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Receive Line Status */
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (LSRValue &amp;amp; (LSR_OE | LSR_PE | LSR_FE | LSR_RXFE | LSR_BI))
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* There are errors or break interrupt */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Read LSR will clear the interrupt */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTStatus = LSRValue;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dummy = LPC_UART-&amp;gt;RBR;/* Dummy read on RX to clear 
interrupt, then bail out */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (LSRValue &amp;amp; LSR_RDR)/* Receive Data Ready */
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* If no error on RLS, normal ready, save into the data buffer. */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Note: read RBR will clear the interrupt */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTBuffer[UARTCount++] = LPC_UART-&amp;gt;RBR;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (UARTCount == BUFSIZE)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTCount = 0;/* buffer overflow */
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; else if (IIRValue == IIR_RDA)/* Receive Data Available */
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Receive Data Available */
&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTBuffer[UARTCount++] = LPC_UART-&amp;gt;RBR;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (UARTCount == BUFSIZE)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTCount = 0;/* buffer overflow */
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; else if (IIRValue == IIR_CTI)/* Character timeout indicator */
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Character Time-out indicator */
&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTStatus |= 0x100;/* Bit 9 as the CTI error */
&amp;nbsp; }
&amp;nbsp; else if (IIRValue == IIR_THRE)/* THRE, transmit holding register empty */
&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* THRE interrupt */
&amp;nbsp;&amp;nbsp;&amp;nbsp; LSRValue = LPC_UART-&amp;gt;LSR;/* Check status in the LSR to see if
valid data in U0THR or not */
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (LSRValue &amp;amp; LSR_THRE)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTTxEmpty = 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UARTTxEmpty = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; }
&amp;nbsp; return;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525611#M8247</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525612#M8248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Thu Aug 07 15:25:56 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yeah I am using the sample UART.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got this working now by updating the system clock before and after UARTInit, which I now re-call after every iap write.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess that erasing the sector was modifying the system clock and throwing off the uart timing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;iap_write(...);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SystemCoreClockUpdate();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;UARTInit(...);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SystemCoreClockUpdate();&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525612#M8248</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: In-Application Programming Erase Sector Works Initially But Fails After Reboot (LPC1313)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525613#M8249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by mroe on Tue Aug 12 14:33:36 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Now my ADC is returning incorrect values after an iap erase sector and reboot - the exact same issue as with the uart.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(1) Does anybody know why I had to call SystemCoreClockUpdate() and re-init the uart module after an iap_write?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(2) Why would an iap erase affect the ADC as well?&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(3) Does an iap erase sector change the peripheral clock when the system reboots?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:55:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/In-Application-Programming-Erase-Sector-Works-Initially-But/m-p/525613#M8249</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:55:04Z</dc:date>
    </item>
  </channel>
</rss>

