Brent Brown wrote: > Don't miss the other point though - a boolean flag (single bit, 0/1) > could be used but if the flag itself was randomly corrupted (software > bug, ESD, EMI, whatever) there would only be a 50/50 chance of > detection. > > Instead here an 8 bit token is used. It is initialised only once, > thereafter modified by each section of code in a prescribed fashion. > Somewhat analogous to a game of > Chinese whispers. Corruption of the token itself now has a 255/256 > chance of detection. I'm no C whiz, but it looks to me like your method degenerates to the same thing as using a single flag bit. > During ISR: > if watchcat = 0xAA > watchcat = !watchcat (invert the value) > > At end of mainline code: > if watchcat = 0x55 > watchcat = !watchcat > reset watchdog I could be wrong about this, but I thought the C "!" operator used in this context does a boolean inversion, not a integer one's complement. If so, you no longer know what the value is after the first watchcat = !watchcat, only that it is now zero if it wasn't and non-zero if it was. If you wanted to check for random corruption you'd have to take the one's complement or XOR with FFh. (Of course that may be what the C "!" does. Like I said, I'm no C whiz and usually have to look these things up on the rare occasions I write C). ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist