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.

TMS320F28P550SJ: CRC16/MODBUS Computation utilizing VCU2 on F28P55x

Part Number: TMS320F28P550SJ

Hi everyone

I am currently trying to replace an older implementation of crc-computation for Modbus. On the new  F28P55x we now want to utilize the capabilities of the VCU2 module. The crc algorithm I want to achive is this one: 

Algorithm   Check Poly Init RefIn RefOut XorOut
CRC-16/MODBUS
MODBUS
0x4B37 0x8005 0xFFFF true true 0x0000

However, my current implementation does not give me the expected results. This is what i have: 

uint16_t modbus_CRC(Frame* frame)
{
    CRC_Obj    crcObj;
    CRC_Handle hCrc = &crcObj;

    // Initialize CRC object
    crcObj.seedValue  = 0xFFFF;             // Modbus initial value
    crcObj.nMsgBytes  = ((frame->size) - 2);    // exclude last 2 bytes (CRC itself)
    crcObj.parity     = CRC_parity_even;    // LSB first (little endian)
    crcObj.crcResult  = 0;
    crcObj.pMsgBuffer = (uint16_t*)frame->data
    crcObj.pCrcTable  = 0;                  // VCU2 doesn't need lookup tables

    // Select the reflected polynomial 0x8005
    crcObj.run = (void (*)(void *))CRC_run16BitPoly1Reflected;

    // Run the CRC computation
    crcObj.run(hCrc);

    return crcObj.crcREsult;
}

My Frame-struct has the data-fields defined as: 

int size;    
unsigned char   data[254]; 

--------------------------------------------------------------------------------------------------------
This would be an example input: 
https://crccalc.com/?crc=006605778899aaa2&method=CRC-16&datatype=hex&outtype=hex

In my data memory i have it as words (16bit values), {0x0000, 0x0066, 0x0005, 0x0077, 0x0088, 0x0099, 0x00AA, 0x00A2}. I would expect the result to be 0xC5B6. 

I assume I need to performe some trickery with the input befor I can run it through the VCU2 but I cant' figure out what. Could somebody provide an example?
 
Thanks for any help in advance! 
Elias