Dear guys,
I am finishing my IAR project on the MSP430F1101A,
I want to add check-sum to my code, I added the code below to compute the check-sum on the run.
now, I am trying to determine the "saved_cs". I generated MSP-430_txt file and I computed the check-sum manually.
Unfortunately the saved_CS and the calc_cs are not equal.
Can someone help?
What is the best way to find out the saved_cs ?
Best,
Erez.
void CalcChecksum(void *Start, unsigned int len,void *cs_add)
{
unsigned long Sum = 0; //the calculation reg
unsigned int *pStart = Start; //programm read pointer
unsigned int *CS_add = cs_add; //cs read pointer
while (len) // sum all the memory words
{
Sum = Sum + *pStart++;
len = len - 2;
WDTCTL = WDTPW + WDTCNTCL; //Periodically clear an active watchdog
}
saved_cs=*CS_add;
calc_cs=(unsigned int)Sum;
if( saved_cs != calc_cs )
{
#ifdef ENABLE_CHECK_SUM
while(1)
WDTCTL = WDTPW + WDTCNTCL; //Periodically clear an active watchdog
#endif
}
}