Other Parts Discussed in Thread: C2000WARE
Hello,
I am currently using the VCU library and develop some basic uses of VCU to compute CRC.
My company Watt &Well, want to use the VCU to calculate the CRC of packets exchanged between two TMSF2837x devices.
As I said my code use the VCU library and is inspired by the ccs example of C2000ware available at C2000Ware_2_00_00_03\libraries\dsp\VCU\c28\examples\crc\2837x_vcu2_crc_16
I tried to reproduce the CRC computation of the reference ASCII string 123456789 or in hexa 0x313233343536373839
Here are the different steps
I declare two array with both endianness
static const uint16_t testInput1[5] = {0x3231, 0x3433, 0x3635, 0x3837, 0x0039};
static const uint16_t testInput2[5] = {0x3132, 0x3334, 0x3536, 0x3738, 0x3900}
Here find the initialization of CRC structure and the computation of the CRC
CRC.seedValue = INIT_CRC16;
CRC.nMsgBytes = 9;
CRC.parity = CRC_parity_even;
CRC.crcResult = 0;
CRC.pMsgBuffer = (uint16_t *)&testInput1[0];
CRC.pCrcTable = (uint16_t *)&crc16P2Table[0];
CRC.init = (void (*)(void *))CRC_init16Bit;
CRC.run = (void (*)(void *))CRC_run16BitTableLookupC;
// Step 3: Initialize the handle
handleCRC = &CRC;
// Step 4: Run the 16-bit table look-up CRC routine and save the first result
CRC.init(handleCRC);
CRC.run(handleCRC);
crcResultC_1 = CRC.crcResult;
CRC.crcResult = 0;
CRC.parity = CRC_parity_odd;
CRC.pMsgBuffer = (uint16_t *)&testInput2[0];
CRC.run(handleCRC);
crcResultC_2 = CRC.crcResult;
crcResultC_1 is equal to 0x31C3 (calculated in CRC_parity_even and is the expected value)
crcResultC_2 is equal to 0x142E (calculated in CRC_parity_odd and is not the expected value)
I expected that both CRC are equal but are not.
I use the following website to have the right answer.
check CRC-16/XMODEM row for the corresponding CRC computation.
Could you explain me the reason of this difference?
Best regards,
Quentin Gaspart
Firmware engineer