What should we check when controller does not run the program?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 18, 2016 by lpcware
Content originally posted in LPCWare by mostafanfs on Sat Apr 23 04:45:17 MST 2016
Here's the deal :
I have a LPC1778 board and I'm sure it's working fine. I use IAP functions. the thing is sometimes after reset the controller runs the new program just fine and sometimes it does not run the code at all !!
I have a bootloader code located at the last sector (sector #29) and I'm not planning on changing that sector. But other sectors (0 ~ 28) may be updated by the bootloader code all the time.
Could that be a problem? (because of the crc or checksum or something else? )

Now I looked and from the documents it seems that controller tries to verify the code located on internal flash first to make sure it's what it should be (determined by the checksum word) and then it jumps to that code.
But I don't know how it does that because I checked and checksum word (4 bytes located at 0x1c address) is just a checksum of previous bytes located at 0x00 through 0x1B .
What about the rest of the code?

I mean what if I changed the code located at last sector just randomly. How can this error be detected by the flash verifying process?
Look at the picture. It's obvious that checksum word is just a checksum from those selected bytes :