MSPM0G3519: CRC16 not working for mspm0

Part Number: MSPM0G3519
Other Parts Discussed in Thread: SYSCONFIG,

Hello, 

For a project that needs CRC16 calculation, I have tried to get the microcontroller CRC peripheral to do the calculation but it does not work.

I have already tried the CRC32 on the microcontroller and it works just fine.

What could be the problem or is there a sample CRC16 project that I could use as a guide.

Thanks.

  • Hi Abayomi,
    Before answering your question, I'd like to confirm a few details:
    Are you using DriverLib functions or direct register operations? Note that the MSPM0G3519 only supports CRC16-CCITT.
    So please make sure your expected output is based on this standard.
    The most common reason CRC16 doesn't work while CRC32 does is bit order (bit reversal) handling. 
    Thanks.
  • Hi Jasper,

    Thanks for the quick reply.

    I am using the Driver Lib genrated by sysconfig for the CRC operation.  

    The snapshot of the Sysconfig is below:

    I have looked at the impementation but I could not find the problem.

    Is there a crc16 example I could use?

    Thanks

  • Hi Abayomi,

    I verified the CRC-P peripheral on the LP-MSPM0G3519 LaunchPad using the official SDK example and confirmed it works correctly.
    After comparing configurations, the SysConfig settings used in the SDK example are shown in the attached screenshot. I'd recommend adjusting your configuration to match.
    With this configuration, computing CRC on the test data
    {0x1234, 0x5678, 0x9012}
    gives a result of
    0x2C81
    You can use the same data to verify your setup.
    If the issue persists after making the adjustment, please provide the following so I can investigate further:
    Your input data (in hex)
    The actual output value you're getting
    Your expected value and how it was calculated

    Thanks
  • Hi,

    Thanks for the reply.

    I would try it out soon.

    I would like to ask it this would also work when calculating the CRC16 of a flash memory area?  The CRC value of the memroy area has already been calculated from the linker command file.

    Thanks.


  • Hi Abayomi,

    Technically, you can use the CRC-P peripheral to calculate CRC16 over a Flash memory area. I recommend reading the Flash data byte by byte for the calculation.
    The key requirement is that the CRC-P peripheral configuration must exactly match the parameters used in the linker command file, including:
    • Polynomial,
    • Seed (initial value),
    • RefIn / RefOut
    Once these are confirmed to match, the results from both sides should align.
    Thanks.
  • Hi Jasper,

    Thanks.  I tried the proposal but the CRC result still did correspond to the linker generated CRC result.

    The implementation is below

    Linker command file:      

    GROUP
    {
      FLASH_APP               : origin = _APP_START_ADDRESS_, length = 0x00070000 - _APP_START_ADDRESS_ - 0x80
    }crc(_flash_crc_table, algorithm=CRC16_802_15_4)
    }
    Calculation in code:
        uint16_t crc_result = DL_CRCP_calculateMemoryRange16(CRCP0, CRC_SEED, (uint16_t *)p_crc_table->recs[0].addr
        (uint16_t *)(p_crc_table->recs[0].addr + p_crc_table->recs[0].size));
    The generated configuration code is below:
    DL_CRCP_setPolynomial(CRCP0, DL_CRCP_CRCPOLY_POLYNOMIAL_16_AUG_CCIT);
        DL_CRCP_init(CRCP0, DL_CRCP_POLYNOMIAL_SIZE_16, DL_CRCP_BIT_NOT_REVERSED,
            DL_CRCP_INPUT_ENDIANESS_BIG_ENDIAN, DL_CRCP_OUTPUT_BYTESWAP_DISABLED);

        DL_CRCP_setSeed16(CRCP0, CRCP_SEED);
    where the CRCP_SEED is  0xF1D
    The configuration using sysconfig is below:
    Where could the problem be.
    Thanks

  • Hi Abayomi,

    Thank you for providing the CRC algorithm information from your Flash - this is very helpful.
    The configuration I shared earlier was based on the SDK example (CRC-16/AUG-CCITT), which was used to verify that the CRC-P peripheral works correctly on the G3519. Since your Flash uses the CRC-16/802.15.4 algorithm, the mismatch is caused by a difference in parameters between the two configurations.
    To match CRC-16/802.15.4, please update the following settings:
    Change Seed to 0x0000
    Change BitOrder to Reversed
    All other parameters can remain unchanged. Please re-verify the result after making these adjustments.

    Thanks.