Content originally posted in LPCWare by Dave on Mon Jul 02 14:05:58 MST 2012
Next thing I did is write a routine that would execute from internal flash... I recognize the UM states that you should execute your code from somewhere OTHER than flash, because code in flash will generate a wait state until the process is complete, but that's okay for me, since I don't have anything else running - so while the process is generating the checksum, I'd be waiting anyway... no big deal...
Here is the code I used:
<code>
// calculate current signature
/* 0 : CLEAR ANY PREVIOUS "DONE" FLAG */
LPC_FMC->FMSTATCLR = (1<<2);
/* 1 : SET THE START AND STOP ADDRESSES... */
LPC_FMC->FMSSTART = (0x00000000)>>4; // start address divided by 16
LPC_FMC->FMSSTOP = (0x0007FFFF)>>4; // stop address divided by 16
/* 2 : START THE SIGNATURE GENERATION... */
LPC_FMC->FMSSTOP |= (1<<17); // enable start bit...
/* 3 : WAIT FOR GENERATION TO COMPLETE... */
while( !(LPC_FMC->FMSTAT & (1<<2)) );
/* 4 : CLEAR "DONE" FLAG */
LPC_FMC->FMSTATCLR = (1<<2);
CurrentFlashSignagure[0] = LPC_FMC->FMSW0;
CurrentFlashSignagure[1] = LPC_FMC->FMSW1;
CurrentFlashSignagure[2] = LPC_FMC->FMSW2;
CurrentFlashSignagure[3] = LPC_FMC->FMSW3;
</code>
and waddya know... the output looked like this:
<code>
FLASH SIGNATURE CHECKSUM: 0x94A71A54 E7B62D82 20239788 48B0EEBC
</code>
Now, I don't know at this stage if these values are right... I will still have to implement the algorithm in the user's manual and double check them manually (See Figure 171), but at least it's a start - no hardware faults or hang ups...
See if this helps,