This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377D: VCU2 CRC8 processing time

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE

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.

  • Pin toggling is not the right way to benchmark such almost nothing to do routines. In CCS >v7 debugger click Run->Clock->Enable. You should see hardware clock in the right bottom edge. Double click on it to reset, then step over your can_calc_crc() call and see something like what I see - 76. I don't know why do you get 8ms. I'm using ControlSuite and CRC lib is v 1_00_02, but it shouldn't differ so much.

    Edward
  • Hi Edward,

    Thanks for the info. I enabled the Hardware clock as suggested and remove the GPIO SET and CLEAR instructions. When stepping over the calc_calc_crc function, I see the counter at the bottom right gets to value 2 and I get this information in the Console window:

    C28xx_CPU1: Breakpoint Manager: Error enabling this function: This task cannot be accomplished with the existing AET resources.
  • Hi Dainius,

    Sorry, on 28377S it is OK, I don't know why it doesn't work on 28377D. Perhaps someone could shed light why do you get "This task cannot be accomplished with the existing AET resources" on 28377D.

    Did you check core clock speed? Is InitSysCtrl() called before CRC routines. Using pin as a benchmark tool please try calling can_calc_crc() say 100 times in a row between setting pin high and low. Time shouldn't increase 100 times. GPIO is quite slow but not in the milliseconds range, 8ms is too much for 8 bytes CRC.

    Edward
  • Hi Dainius,

    I'll work with you to try and resolve this issue. Please give me a day to review the information and get back to you.

    Thanks,
    Sira
  • Dainius,

    In your project, is VCU support enabled - right-click on project properties, under Build-c2000 compiler - Processor options - can you check if --vcu_support is set to vcu2?

    Thanks,
    Sira
  • One more thought would be for you to check exactly how long CRC.run(handleCRC) takes to execute, since this is what is of concern here.

    Thanks,
    Sira
  • Do you have any updates? If your questions have been answered, I would like to go ahead and mark the issue as resolved. It would help if you could mark my Answer as Verified as well. Thanks! -Sira