AnsweredAssumed Answered

Issue while calculating the CRC for logical address block in Flash

Question asked by sudheer rajulapudi on Jun 26, 2013
Latest reply on Jun 26, 2013 by Radek Sestak

Hi all,

 

I came accross with an issue , while i am calculating the CRC for particular location in Flash memory.

In File1.c(for reference), i am passing start and end address of the block to fucntion where calculating the CRC.

 

But, while Debuging  i noticed that, CRC calculating for 8000 to FFFF instead of 7EC000 to 7EFFFF.

and while returning the value it's returning 2 byte value instead of 4 byte value.

but variable crc holding the 4 bytes values

 

IDE: CW

Microcontroller: MC9S12XS128

 

file1.c

#define BLOCK1START      0xFB8000

#define BLOCK1END        0xFBBFFF

 

crcBoot[0]= _Checksum_CheckAreaCRC32_PreCalc(BLOCK1START,((BLOCK1END+0x1)-BLOCK1START));

 

file2.c

_CheckSum4ByteType _Checksum_CheckAreaCRC32_PreCalc(_CHECKSUM_ConstMemBytePtr start, unsigned int len) {

  const _CheckSum1ByteType*_CHECKSUM_QUALI ptr= (const _CheckSum1ByteType* _CHECKSUM_QUALI)start;

  _CheckSum4ByteType crc = 0xFFFFFFFF;

 

  const _CheckSum1ByteType* _CHECKSUM_QUALI endPtr= ptr + len;

  while (ptr != endPtr) {

     

      crc= CheckSumByteCRC32_PreCalc(crc, *ptr);

    //__FEED_COP;     /* COP enabled? If so, feed it */

    PTM=PTM^0x04;     /* toggle self reset */

    ptr++;  

   

  }

    return (crc); /*== check->checkSumCRC32 *

 

please help me on above issue, how to pass address properly and how to return values correctly without losing 2 bytes value...

 

thanks in advance

 

 

Outcomes