My book tells me that a checksum byte in rom is performed to insure the integrity of ROM contents. It will detect any corruption of the contents of ROM. I don't understand this. I thought memory stored in ROM is read only so how can it be manipulated? What does it mean corrupted? It says corruption can be caused during start up due to current surge. If memory is lost or corrupted then what does the checksum do to correct it, in other words does it restore it or delete it or what?
I am performing this instruction on a HCS12 microcontroller from freescale using code warrior. The language i'm using to do the checksum is written in C.
The ROM is actually EEPROM (Electrically Erasable Programmable Read-Only Memory), which can be programmed and reset. It is not true ROM. So the checksum would be used to determine if there was a problem when the EEPROM was programmed. Programming devices for EEPROMs will also commonly read back what they have written to confirm it all went ok.
During normal operation, your microcontroller isn't updating this and it's called "ROM" because the data is stable when it's powered down. It would be programmed: