2023-02-13 12:03 AM
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.
Solved! Go to Solution.
2023-02-13 7:49 AM
Hello ,
Interesting issue ;)
Could you try your software code in SPC58EC ?
Could you check this application SPC560Pxx OS-Less CRC Test Application for Discovery
there is a CRC calculation SW.
Best regards
Erwan
2023-02-13 7:49 AM
Hello ,
Interesting issue ;)
Could you try your software code in SPC58EC ?
Could you check this application SPC560Pxx OS-Less CRC Test Application for Discovery
there is a CRC calculation SW.
Best regards
Erwan
2023-02-13 6:08 PM
hello.
thanks for your answer.
i already used SPC58ECxx_RLA CRC Test Application for Discovery.(the same SPC560Pxx OS-less....)
Firmware has already applied the above code to create the CRC.
i should compare the two by making CRC in the window program with the same image.
I'm inquiring because these two crc values are different.
best regards.
Pil
2023-02-13 6:35 PM
For left shifting you'd need to get the data into the high order bits, surely?
CRC = ((uint)(ch) << 24) ^ CRC;
CRC are very sensitive to exact bit order, byte ordering, shift direction, etc.
If you've got anything wrong, you'll get different numbers, so pay particular attention to the details.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.