CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Calculate/verify ROM checksum

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stevev
Guest







Calculate/verify ROM checksum
PostPosted: Thu Feb 20, 2003 8:32 pm     Reply with quote

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
PostPosted: Fri Feb 21, 2003 8:20 am     Reply with quote

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: 11955
stevev
Guest







Re: Calculate/verify ROM checksum
PostPosted: Fri Feb 21, 2003 9:24 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group