AnsweredAssumed Answered

CRC computation shows different results

Question asked by Nicolas G on Apr 9, 2018
Latest reply on Apr 13, 2018 by Nicolas G



I have TWR-K64F120 and I use KDS (3.0.0) with KSDK (1.3.0). To compute the CRC, I use the fsl_crc module which provides the function "CRC_DRV_Get_CrcBlock" to compute the CRC. The module is configured to compute the CRC16 CCITT (polynomial is 0x1021). The result given the first time is correct and then... all the subsequent results are false, even if the same data is given!


My (simplified) test code is as below:

    uint8_t test_array[2] = { 0 };

    test_array[0] = 0x01;

    test_array[1] = ~test_array[0];
    uint32_t crc_computed = CRC_DRV_GetCrcBlock(crc16_CCITT_IDX, test_array, 2);

The first time the function is called, the result is 0x20EF which is expected. Calling the function after that always give a wrong (and different) result. Could you kindly help me to understand what I do (or don't do) which could cause the error?