> John Payson wrote: > > > The only time a ROM checksum routine is really useful is if > > the checksum routine itself is stored in a more reliable > > medium than the code being checked. > > I agree with part of the comment however the real role of a > checksum routine is to prevent in-operative code from > executing. Careful design of the checksum routine can > result in the failure modes of the checksum preventing the > application from running. In critical systems the checksum > routine which is quite small becomes the focus of very careful > anaylsis. If a checksum routine is designed very carefully, it may be possible to ensure that some failure modes of the checksum program memory will result in an inoperable system (rather than one which operates wrongly). In practice, though, I would tend to question the usefulness of such tech- niques on single-chip micros with a unified code store (as opposed to chips which have some ROM/OTPROM and some "live-programmable" EEPROM). In cases where it's plausible that some of the code might be damaged without render- ing the whole CPU entirely unreliable (e.g. in larger systems where the code is spread out over several chips, or in cases where some of the code in in user-insertable modules as with game machines) a checksum may be an excell- ent way of ensuring that all is as it should be. In fact, an excellent way of designing a field-upgradable system would be to use a 17Cxx with an ext- ernal flash; the internal OTPROM could checksum the external memory and run it only if it looked okay. For a PIC running internal code, however, I'm not aware of any plausible* failure modes that would allow a checksum rou- tine to detect the problem and act accordingly. (*) By this I mean failure modes which are at least 10% as likely as more common failure modes. If a system has a 1% chance of having its CPU start operating sporatically in a year, and a 0.1% chance in that same year of having its memory lose a few bits and the CPU detect the sit- uation, the CRC routine hasn't really bought much.