Content originally posted in LPCWare by jdurand on Sun Dec 02 16:18:44 MST 2012 Just something I noticed with CRP:
Since we program our production parts with SWD, I can't have the CRP set since that will make programming/verification fail (per NXP app. note).
So, I set the CRP_WORD to -1 (0xFFFFFFFF) and since we store serial numbers in our parts, I just defined it as an INT.
During initialization I check if the serial number is > 0 (blank/default would be -1), if it is it's assumed this is a production unit going out to a customer and I then use IAP to write CRP-2 over the CRP-word and then call NVIC_SystemReset().
This works fine with one footnote: Stepping through the code with CodeRed and a Red Probe + on an LPC1226/301 (haven't tried any other method or processor yet) after the NVIC_Reset I can STILL continue debugging the code.
But, if I exit debug mode and try to re-enter, then I can't. So, it seems the CRP_Word isn't read from a soft RESET or else it doesn't matter if the SWD is currently active.
In our case, it doesn't matter since the device will be powered off at least once before the customer gets it.
One other thing that's possible, you could have some strong password on your system that would let you clear the CRP word back to -1 to re-enable debugging, if you have a need. Or just use Flash Magic for the single purpose of erasing all of FLASH and then go back to SWD.