Part Number:TMS320F28377D
Hi,
I've integrated VCU CRC8 library from C2000Ware 1.00.03.00 package into my CCS project. I am intending to generate a CRC8 of the bytes in a CAN message. And yes, I know CAN already does a CRC for the message.
Anyway, I've used the examples in the C2000Ware_1_00_03_00_Software\libraries\dsp\VCU\c28\examples\crc\2837x_vcu2_crc_8 project and implemented them in my codebase.
I am only trying to generate CRC8 on 8 bytes. I have found that for the VCU, the bytes need to be packed into uint16_ts. I've confirmed that the CRC8 is correct and I am happy with the data.
What is really troubling me, is that it takes over 8ms to generate a CRC8 if using assembly based functions and even longer if using C based functions. I am only generating CRC8 on 8 bytes, 4 words. Please see my configuration below:
/** * CRC object initialisation. No buffer or byte count as they will differ per CAN message. */ static void can_init_crc(void) { /* Step 1: Initialize the CRC object */ CRC.seedValue = INIT_CRC8; CRC.nMsgBytes = 0; CRC.parity = CRC_parity_even; CRC.crcResult = 0; CRC.pMsgBuffer = 0; CRC.pCrcTable = (uint16_t*)&crc8Table[0]; CRC.init = (void (*)(void*))CRC_init8Bit; CRC.run = (void (*)(void*))CRC_run8Bit; /* Step 2: Initialize the handle */ handleCRC = &CRC; /* Step 3: Run the 8-bit table look-up CRC routine and save the result */ CRC.init(handleCRC); }
/** * Function to calculate CRC* on the given payload array. * */ static inline uint16_t can_calc_crc(uint16_t* payload, uint16_t dlc) { uint16_t resp = 0U; uint16_t packed_payload[4U] = {0}; uint16_t wordIdx = 0U; /** * Pack each byte in payload into continuous data LSBMSB format * payload[n] -> packed[word](LSB) * payload[n+1] -> packed[word](MSB) */ for(uint16_t id = 0U; id < dlc; id += 2) { packed_payload[wordIdx] |= (payload[id]); packed_payload[wordIdx] |= (payload[id + 1] << 8); wordIdx++; } CRC.pMsgBuffer = packed_payload; /* -1 to not include the CRC byte in calculation */ CRC.nMsgBytes = dlc - 1; CRC.run(handleCRC); resp = (uint16_t)CRC.crcResult; CRC.crcResult = 0; return (resp); }
Using oscilloscope and some GPIO toggling, I can see that the "can_calc_crc" function takes 8ms to return. Is this normal? Is there some flag that I need to enable the VCU explicitly? I am using VCU2 and the library included is "c28x_vcu2_library_fpu32.lib"
Kind regards.