Hi ,
I am using the crc-engine in the MSP430F5435A, for checking FLASH and I am having confusion in implementation. I am a new to this platform.
Do I have to do:
if(crc16Check()!= 0)
{
printf("CRC16 Error"); //enable alarm LED
while(1);
}
UINT16 crc16Check(void)
{
unsigned int length;
unsigned short crc16;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
length = sizeof(CRC_TEST_SEQ)-1;
printf("\nMessage: %s (len = %d)\n\n", CRC_TEST_SEQ, length);
// calculate CRC with table method
crc16 = crc16MakeTableMethod(CRC16_INIT_REM, crc16Table, msg, length);
printf("CRC16_tab: 0x%X(N)\n", crc16);
return (0);
}
unsigned short crc16MakeTableMethod(unsigned short crc, TBL_MEM unsigned short *table,
unsigned char *pbuffer, unsigned int length)
{
while(length--)
crc = table[((crc >> 8) ^ *pbuffer++)] ^ (crc << 8); // normal
return(crc ^ CRC16_FINAL_XOR);
}
#############################################################
OR
Do i have to calculate as per Note :
Checksum calculation made by XLINK
You can use these options either in your linker command file (filename .XCL) or in the Embedded Workbench.
In the EW you set up calculation of the checksum in the Project > Options > Linker (XLINK) > Processing. The options that corresponds to the examples are Fill unused code memory (command line option H); Fill pattern (any pattern); Generate checksum (command line option J); size = 2 bytes; CRC16; Complement = as is; Bit order = MSB first.
From command line (or in the .xcl file) you use the -J and -H linker options for calculating the checksum. Note that you must use the -H filler byte option to be able to use -J.
There are some requirements that you have to fulfil to make this work.
| • |
You must ensure that the segment in which the checksum itself is stored has a proper address and address range. -Z(CODE)CHECKSUM=1000-1001 /* In this example a two byte checksum */ |
| • |
You should have both a start and stop address defined for all code segments. -Z(CODE)CODE_SEGMENT /* Wrong */ -Z(CODE)CODE_SEGMENT=2000 /* Wrong */ -Z(CODE)CODE_SEGMENT=2000-4FFF /* Correct */ |
| • |
As long as you have both start and stop addresses you can have more than one CODE memory range. -Z(CODE)FIRST_CODE_SEGMENT=2000-4FFF -Z(CODE)SECOND_CODE_SEGMENT=7000-9FFF
Regards, Ran |