Calculate crc in spc5studio and SPC58ECxxxx MCUs
I am using spc5studio and SPC58EC80E1.
i import crc sample from application library.
i set CRC Settings at low level Drivers component RLA
- CRC-32, Polymonial seed 0x4c11db7, reset = 0xFFFFFFFF
and firmware code
-----------------------------------------------------------------------------------------------------
const CRCContextConfig *crc_ctx_config[] = {
&crc_context_config_contex_crc32,
};
(void)crc_lld_start(&CRCD1);
(void)crc_lld_start_context(&CRCD1, 0, crc_ctx_config[0]);
if (crc_lld_calc(&CRCD1, 0, startAddress, (uint32_t)length, &calculatedCRC) != CRC_NO_ERROR) {
osalThreadDelayMilliseconds(100);
}
(void)crc_lld_stop_context(&CRCD1, 0);
(void)crc_lld_stop(&CRCD1);
-----------------------------------------------------------------------------
The code for the window is as follows.
uint Polynominal = 0x04C11DB7;
uint InitValue = 0xFFFFFFFF;
int i= 0, j = 0;
uint CRC = 0xFFFFFFFF;// InitValue;
for (i = 0; i < nByte; i++)
{
byte ch = c[i];
for (j = 0; j < 8; j++)
{
CRC = (uint)(ch ^ CRC);
if ((CRC & 0x80000000) != 0)
{
CRC = (CRC <<1) ^ Polynominal;
}
else
{
CRC <<= 1;
}
}
}
---------------------------------------------------------------------------------
later
I checked crc value the image of flash, but it is different from the CRC-32 calculation in windows program.
I want to know how to calculate the application library.
Or, I would appreciate it if you could let me know if my code is wrong.
thanks.
regards.
