<?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: IAP EEPROM Anomaly LPC11U68</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630452#M24800</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to hear you solved your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Keil there is a simple check box for this. For every source file an assembly file (*.txt) is generated containing the source code as comments.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Nov 2016 16:27:38 GMT</pubDate>
    <dc:creator>wernerf</dc:creator>
    <dc:date>2016-11-04T16:27:38Z</dc:date>
    <item>
      <title>IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630444#M24792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;This causes a Hard Fault IRQ when iap_entry() is called (only partial code shown, the other provisions are coded):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;uint32_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clock_speed;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;clock_speed = 12000000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; iap_command[0] = IAP_EEPROM_WRITE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; iap_command[1] = eeprom_start_address;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; iap_command[2] = (uint32_t)byte_ptr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; iap_command[3] = byte_count;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; iap_command[4] = clock_speed / 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_entry( iap_command, iap_result );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;But this works fine:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;clock_speed = 12000000 / 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_command[0] = IAP_EEPROM_WRITE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_command[1] = eeprom_start_address;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_command[2] = (uint32_t)byte_ptr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_command[3] = byte_count;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_command[4] = &lt;SPAN&gt;clock_speed&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;iap_entry( iap_command, iap_result );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;This makes no sense to me. &amp;nbsp;Is this a compiler bug, possibly due to optimization?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;I'm using LPCXpresso IDE v7.6.2 [Build 326] for LPC11U68.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: georgia, palatino, serif;"&gt;Matt&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2016 21:39:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630444#M24792</guid>
      <dc:creator>mattferrari</dc:creator>
      <dc:date>2016-11-03T21:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630445#M24793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is normal. IAP&amp;nbsp;functions &lt;SPAN&gt;require&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;the frequency in kHz.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 00:08:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630445#M24793</guid>
      <dc:creator>pavelhudecek</dc:creator>
      <dc:date>2016-11-04T00:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630446#M24794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please have another look at my code. &amp;nbsp;In BOTH cases, the value being assigned to iap_command[4] is the same, 12000. &amp;nbsp;In the first case, I divide the variable by 1000 at the assignment, in the second case, I divide the variable first, then assign it as a single entity. &amp;nbsp;The problem here in not the value (kHz). &amp;nbsp;I understand that, and in both cases, the value being assigned is 12000. &amp;nbsp;So why does one work and the other not?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 00:31:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630446#M24794</guid>
      <dc:creator>mattferrari</dc:creator>
      <dc:date>2016-11-04T00:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630447#M24795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's weird. Optimization possibly might cause it, but:&lt;/P&gt;&lt;P&gt;I had a similar strange problem:&lt;BR /&gt;1. clock_speed set at program startup.&lt;BR /&gt;2. Overwriting of clock_speed occured, due to array index&amp;nbsp;overflow in a completely different part of the program.&lt;BR /&gt;3. I use clock_speed to set iap_command[4] and the IAP crashed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 01:19:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630447#M24795</guid>
      <dc:creator>pavelhudecek</dc:creator>
      <dc:date>2016-11-04T01:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630448#M24796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's the complete function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define PREVENT_IRQS { \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; reenable_irq = !(__get_PRIMASK()); \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; __disable_irq(); \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define RESTORE_IRQS { \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; if( reenable_irq ) \&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; __enable_irq(); \&lt;/SPAN&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;#define SYSTEM_CLOCK_SPEED_UPON_RESET&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;12000000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;uint32_t ReadEEPROM( bool pre_clock_config, uint32_t eeprom_start_address, uint32_t *dst_ptr, uint32_t byte_count )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint32_t &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_command[6], iap_result[6], clock_speed_kHz;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;volatile uint8_t &amp;nbsp;&amp;nbsp;&amp;nbsp;*byte_ptr, reenable_irq, retry = 50;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;byte_ptr = (uint8_t *)dst_ptr;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( pre_clock_config )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clock_speed_kHz = SYSTEM_CLOCK_SPEED_UPON_RESET / 1000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;clock_speed_kHz = SystemCoreClock / 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;PREVENT_IRQS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;try_again:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Load IAP Command Buffer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;iap_command[0] = IAP_EEPROM_READ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;iap_command[1] = eeprom_start_address;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;iap_command[2] = (uint32_t) byte_ptr;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;iap_command[3] = byte_count;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;iap_command[4] = clock_speed_kHz;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;iap_entry( iap_command, iap_result );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if( (iap_result[0] != IAP_CMD_SUCCESS) &amp;amp;&amp;amp; retry-- )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;goto try_again;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;RESTORE_IRQS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return( iap_result[0] );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code seems to work just fine. &amp;nbsp;But if I don't do the "divide by 1000" in the upper code and instead try to do it right there at the iap_entry[4] assignment (as in my prior email) I crash upon entering iap_entry(). &amp;nbsp;I set up my LPCXpresso11U68 board as a debug interface to my target and single stepped the code using the LPCXpresso IDE. &amp;nbsp;I confirmed the value of the variable used at the [4] assignment - it is correct immediately prior to calling iap_entry(). &amp;nbsp;When I set a breakpoint immediately after the call to iap_entry() and run the code, I immediately trap to the HardFault ISR. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I put all constants at the [4] assignment (i.e. 12000000 / 1000) it works. &amp;nbsp;If I assign the single (predivided) value at the [4] assignment it works. &amp;nbsp;But if I use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iap_command[4] = clock_speed / 1000; (Where clock_speed is confirmed to have a value of 12000000 as observed in the debugger) I crash.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see in the above code, I am disabling interrupts and my "clock_speed" variable is an automatic/local variable on the stack, so it shouldn't be getting overwritten.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing this function right after reset, before calling the ResetISR() initialization function. &amp;nbsp;Are there any resources that I need to have configured or enabled (e.g. clocking) in order to use the IAP call? &amp;nbsp;The Stack Pointer would have been initialized via the Vector Table as specified in the Linker Script: &amp;nbsp;PROVIDE(_vStackTop = __top_Ram0_32 - 64);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, I am leaving the uppermost 32 bytes of the Stack free for the IAP resource (as required) and an additional 32 Bytes as well... &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now that you can see the whole code and you know that I'm calling this function right after reset, does anything come to mind explaining why:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iap_command[4] = clock_speed_full / 1000;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// FAILS (clock_speed_full = 12000000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iap_command[4] = clock_speed_alone;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// WORKS &amp;nbsp; (clock_speed_alone = 12000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iap_command[4] = 12000000 / 1000;&amp;nbsp;&amp;nbsp;&amp;nbsp;// WORKS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My concern is that if I don't understand what's happening, there could be an issue which might manifest elsewhere, so it's important to understand what's happening here - it could be pointing to a bigger problem that needs to be addressed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 03:03:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630448#M24796</guid>
      <dc:creator>mattferrari</dc:creator>
      <dc:date>2016-11-04T03:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630449#M24797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Strange.&lt;BR /&gt;The division on 11U68 is realized via ROM functions, that may be required some initialization. Is this problem occurs, if you called your function after ResetISR()?&lt;BR /&gt;The division may fail and:&lt;BR /&gt;1. Content of iap_command[4] is possibly incorrect.&lt;BR /&gt;2. Stack or some system variables is possibly incorrect.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 10:13:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630449#M24797</guid>
      <dc:creator>pavelhudecek</dc:creator>
      <dc:date>2016-11-04T10:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630450#M24798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the only difference in the three lines of code is that only the first line has the division at run-time. In the third line the division is performed by the compiler's preprocessor and a simple constant is loaded into iap_command[4].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you set the debuggers breakpoint right before the iap call and confim what value is in iap_command[4] ?&lt;/P&gt;&lt;P&gt;Alternatively, can you look into the assembly code the compiler has produced?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 10:16:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630450#M24798</guid>
      <dc:creator>wernerf</dc:creator>
      <dc:date>2016-11-04T10:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630451#M24799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your replies. &amp;nbsp;The mystery has been solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is due to performing a division operation prior to initializing the pDivRom_uidiv variable. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ROM divide variables are initialized in ResetISR() which is &lt;SPAN style="text-decoration: underline;"&gt;normally&lt;/SPAN&gt; called directly from the Reset Vector:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unsigned int *div_ptr = (unsigned int *)((unsigned int *)*(PTR_ROM_DRIVER_TABLE))[4];&lt;BR /&gt;pDivRom_idiv = (unsigned int *)div_ptr[0];&lt;BR /&gt; pDivRom_uidiv = (unsigned int *)div_ptr[1];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But since I am performing a divide function &lt;SPAN style="text-decoration: underline;"&gt;prior&lt;/SPAN&gt; to calling ResetISR() the variables are not yet initialized.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The failure wasn't actually in the iap_entry() function as I had thought, but rather the code crashes when attempting to perform the divide function for the value that is to be loaded into iap_command[4].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the assembly code that's called when the division is to occur:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__aeabi_uidiv:&lt;BR /&gt; push {r4, lr}&lt;BR /&gt; ldr r3, =pDivRom_uidiv&lt;BR /&gt; ldr r3, [r3, #0] // Load address of function&lt;BR /&gt; blx r3 // Call divide function&lt;BR /&gt; pop {r4, pc}&lt;/P&gt;&lt;P&gt;.endfunc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Hard Fault occurs when the "blx" command is executed, obviously because "r3" got a bad value since pDivRom_uidiv had never been set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help with resolving this problem. &amp;nbsp;Understanding this situation is very important because now I know not to perform any division operations prior to this initialization. &amp;nbsp;Usually, this initialization happens right away and no thought is given to it, but in a situation like mine, that initialization is missing and that's the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One last question... &amp;nbsp;If I want to generate a "mixed listing" from my build which includes the assembly code interspersed with the source code, is there a setting in one of the "Project" &amp;gt; "Properties" panels for generating such an output file from the build?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 15:37:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630451#M24799</guid>
      <dc:creator>mattferrari</dc:creator>
      <dc:date>2016-11-04T15:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630452#M24800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to hear you solved your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Keil there is a simple check box for this. For every source file an assembly file (*.txt) is generated containing the source code as comments.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 16:27:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630452#M24800</guid>
      <dc:creator>wernerf</dc:creator>
      <dc:date>2016-11-04T16:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: IAP EEPROM Anomaly LPC11U68</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630453#M24801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Werner, but I'm using the LPCXpresso IDE. &amp;nbsp;How do I generate a mixed listing from my build using the LPCXpresso IDE?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Nov 2016 16:46:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/IAP-EEPROM-Anomaly-LPC11U68/m-p/630453#M24801</guid>
      <dc:creator>mattferrari</dc:creator>
      <dc:date>2016-11-04T16:46:25Z</dc:date>
    </item>
  </channel>
</rss>

