How do I calculate a checksum of the flash ROM in a 16F877 device? From the manual it appears that the compiler will set environment variable ID to the rom checksum at program time if you use the "#ID CHECKSUM" directive, and you can access the stored ID with GETENV(ID), but how do you calculate the checksum at run time when starting up to verify all is the same as when the chip was programmed?
I didn't see this discussed in prior posts so any help would be most appreciated.
Thanks, -steve-
___________________________
This message was ported from CCS's old forum
Original Post ID: 11943
Jon Fick Guest
Re: Calculate/verify ROM checksum
Posted: Fri Feb 21, 2003 8:20 am
The CCS manual shows the following that is applicable only to devices that can read from program memory using the read_program_eeprom command.
Jon
___________________________
This message was ported from CCS's old forum
Original Post ID: 11955
stevev Guest
Re: Calculate/verify ROM checksum
Posted: Fri Feb 21, 2003 9:24 am
Thanks, I tried that but the value I get doesn't match the ID retrieved with "#ID CHECKSUM". Looking at the Microchip stuff it seems the checksum they expect in the hex file is a 12-bit sum. Does that mean masking each word to 12-bits before adding? Or masking off the total to 12-bits? None of these things seem to work.
Does anybody have any code where they have done this before? I'm just stabbing in the dark trying to perform what should be a simple check.
Any help or code would be appreciated! -steve-
:=The CCS manual shows the following that is applicable only to devices that can read from program memory using the read_program_eeprom command.
:=
:=checksum = 0;
:=for(i=0; i<8196; i++)
:= {
:= checksum^=read_program_eeprom(i);
:= }
:=printf("Checksum is \%2X\r\n",checksum);
:=
:=Jon
___________________________
This message was ported from CCS's old forum
Original Post ID: 11960
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum