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.

MSP430FR5739: Matching Hardware CRC16 CCITT generated on MSP432E401Y to 16-bit Hardware CRC-CCITT-BR on MSP430FR5739

Part Number: MSP430FR5739
Other Parts Discussed in Thread: MSP432E401Y

Hi TI Experts, 

I am working on a communication protocol between the MSP432E401Y and the MSP430FR5739, which requires 16-bit hardware CRC generation. I am using the driver libraries on both the MSP432 and the MSP430 to interface with each CRC driver to generate a 16-bit CRC. Data input to the drivers is 1 byte at a time (unsigned char or uint8_t type).

The MSP432 has several CRC standards to choose from, but the closest to the MSP430 is the CCITT option. The MSP430 has the 16-bit CRC-CCITT-BR (BR=byte reversed?) standard (cannot be changed), so it is not exactly the same as the MSP432.

Below is the example for the MSP432E401Y I am following, modified to show my CRC configuration and parameters entered. The data I am creating the checksum for is also the same. The CRC16 result  = unsigned short 1111111101110100b (Binary)

/*
 *  ======== crc.c ========
 */
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

/* Driver Header files */
#include <ti/drivers/CRC.h>

/* Driver configuration */
#include "ti_drivers_config.h"

/* Expected CRC for CRC_32_IEEE with full endianness reversal */
static const uint32_t expectedCrc = 0x4C4B4461;

/* Example test vector */
static const size_t srcSize = 3;
static const uint8_t src [] = {
    0x02,0x08,0x01
};


/* ======== mainThread ======== */
void *mainThread(void *arg0)
{
    int_fast16_t status;
    uint16_t result;

    CRC_Handle handle;
    CRC_Params params;

    /* Initialize the drivers */
    CRC_init();

    /* Set data processing options, including endianness control */
    CRC_Params_init(&params);
    params.byteSwapInput = CRC_BYTESWAP_UNCHANGED;
    params.returnBehavior = CRC_RETURN_BEHAVIOR_BLOCKING;
    params.polynomial = CRC_POLYNOMIAL_CRC_16_CCITT;
    params.dataSize = CRC_DATA_SIZE_8BIT;
    params.seed = 0xFFFF;

    /* Open the driver using the settings above */
    handle = CRC_open(CONFIG_CRC_0, &params);
    if (handle == NULL)
    {
        /* If the handle is already open, execution will stop here */
        while(1);
    }

    /* Calculate the CRC of all 32 bytes in the source array */
    status = CRC_calculateFull(handle, src, srcSize, &result);
    if (status != CRC_STATUS_SUCCESS)
    {
        /* If the CRC engine is busy or if an error occurs execution will stop here */
        while(1);
    }

    /* Close the driver to allow other users to access this driver instance */
    CRC_close(handle);


    return NULL;
}

Below is the example code for the MSP430FR5739 I am following, modified to show my configuration, parameters and data entered. The resulting CRC16 crcResult  = unsigned int 1011011111011001b (Binary) 

#include "driverlib.h"

uint16_t crcResult;

void main (void)
{
    uint16_t crcSeed = 0xFFFF;
    uint8_t data[] = {0x02,
                           0x08,
                           0x01};

    uint8_t i;

    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //Set P1.0 as an output
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN0);

    //Set the CRC seed
    CRC_setSeed(CRC_BASE,
        crcSeed);

    for (i = 0; i < 5; i++)
    {
        //Add all of the values into the CRC signature
        CRC_set8BitDataReversed(CRC_BASE,
            data[i]);
    }

    //Save the current CRC signature checksum to be compared for later
    crcResult = CRC_getResult(CRC_BASE);

    //Enter LPM4, interrupts enabled
    __bis_SR_register(LPM4_bits);
    __no_operation();
}

I have attempted to enter the reversed byte on the MSP430, hoping to get back the CCITT standard without reversed bytes, so I can match it to the CCITT CRC16 standard on the MSP432. However, I may be implementing this wrong. Can someone please show me how I can modify this example code on the MSP430 or the MSP432, so I can match the calculated CRC on the two devices.

Hope this is possible using the hardware CRC generators on these two devices. Looking forward to a solution.

  • This was originally posted using the MSP432E401Y part number. I was asked to open a new ticket specifying MSP430 for the part number.

  • Hi Parryh,

    As an FYI, the BR in the CRC-CITT-BR module appears to stand for bit reversed, not byte reversed. See section 9 of the MSP430FR57xx Family User's Guide for more information. The MSP432E401Y also seems to have an option for bit-reversal available in the CRCCTRL register.

    Also, it looks like in your for loop you are accessing up to index 4 of the array data, but this array has only 3 elements, so the data you are feeding into the CRC module could be anything past that point.

        for (i = 0; i < 5; i++)
        {
            //Add all of the values into the CRC signature
            CRC_set8BitDataReversed(CRC_BASE,
                data[i]);
        }
    

    uint8_t data[] = {0x02,
                        0x08,
                        0x01};

    Best Regards,
    Brandon Fisher

  • Thanks for letting me know Brandon. I have investigated this further and found that the CRC on the MSP430 I calculated is correct. It is the MSP432 that is not behaving how it should. I have opened a new ticket for this under the MSP432 part number (2) MSP432E401Y: Hardware CRC for 16-bit CCITT standard always has 0xFF for upper byte - Arm-based microcontrollers forum - Arm-based microcontrollers - TI E2E support forums. Maybe you might have an idea of why this is happening?

  • Hi Parryh,

    Thank you for the confirmation. I'll let the MSP432 expert comment on that thread. In theory the only things that should be able to go wrong with a CRC modules like this are either the settings or the data being input. Your MSP432 settings seem okay to at the driver level, and I know you've tried inputting the data in different orders. 

    Can you try setting the crc seed value to 0xFFFF FFFF? That seed register is a 32-bit register, that is being initialized with 0xFFFF, so technically it would be 0x0000 FFFF. I'm not sure how the CRC-16 algorithm in the MSP432 is handling that, but it should be a simple check.

    After that, id recommend running this in Debug mode, and looking at the register view for the CRC module in CCS. I would compare the CRCCTRL register values with your expected settings. 

    Best Regards,
    Brandon Fisher

  • The MSP430 does in fact have options. There is a CRCDI and CRCDIRB register for data input. The RB register reverses the bit order. There are also two versions of the results register. Perhaps the driver library that you are using doesn't provide all of these options but the hardware does.

    It can be a bit tedious figuring out how to get the results you expect. I did that when I wanted to write some code that would provide a software CRC or use the hardware when available.

**Attention** This is a public forum