> But, how long does it take to checksum a long block of code (say 6K words) ? It only takes a few instructions to read a program memory location, so add some overhead for the loop and test conditions and figure it out yourself. I haven't done this calculation myself, but my uploader checksums 8000 instructions instantaneously in human time. > If you are curious, the application is a UPS system which is flash > upgradable > through RS232 uplink to the PC its powering. > But when the code is being updated, the PIC will just have to sit like a > dumb moron > forgetting all its complex functions and it won't be able to switch to > battery power > if the power is to fail. Is that really such a big deal? Uploading new code only takes a minute or two, is a rare occurrance, and is only done when the user explicitly requests it, right? If so, a human is right there and can manually deal with a power failure at that time. Of course the PIC code will have to protect itself from a partially uploaded program. > I could possibly do something like write all the code in a particular page > into an > unused page and then copy the code from there to page 0 and 1(This is > because I know > that my code won't exceed 4K words). No matter what you do, there will be some window of vulnerability. This method will make that window short but not eliminate it. My units will be field upgradable by end customers, so they have to be fail safe. They can still be messed up, but that would require a data error or power fail during upload, AND hit the one in 16,000 chance of the checksum matching a random number. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics