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.

CCS/MSP430FR2476: Another TLV structure checksum?

Part Number: MSP430FR2476

Tool/software: Code Composer Studio

Hello,

I'm trying to verify the TLV CRC on an MSP430FR2476.  I found this other thread for the 2422:

It looks like the solution was the CRC end address had to be changed because it was incorrect in the data sheet.  Here are the values in the 2476 data sheet:

Which don't match the ones in msp430fr2476.h:

#define TLV_CRC_START (0x1A04) /* Start Address of the CRC protected structure */
#define TLV_CRC_END (0x1A77) /* End Address of the TLV protected structure */

I've tried both values, and others, in my code but get a failure each time:

  #define BYTE_SIZE_BITS  8       /**< Number of bits in a byte. */
  #define CRC_INIT 0xFFFF

static bool validateTLV(void) {
    bool checkRes = false;
    UINT16 calculatedCrc = 0;
    UINT16 i = 0;
    UINT16 readWord = 0;

    // Declare pointer to access CRC value
    UINT8 * pCrcValueAddr = (UINT8 *)(TLV_CRC_VALUE);

    // Get the CRC stored in the TLV register for comparison
    UINT16 crcValue  = (*pCrcValueAddr << BYTE_SIZE_BITS) |
            *(pCrcValueAddr+1);
    
    // Calculate the CRC
    CRCINIRES = CRC_INIT; // Init CRC with 0xFFFF

    // Go through the TLV CRC address range
    for (i = TLV_CRC_START; i < TLV_CRC_END; i += 2)
    {
        readWord = *(UINT16*) i;
        CRCDIRB = readWord;
    };

    calculatedCrc = CRCINIRES;

    if( calculatedCrc == crcValue ) {
        checkRes = true;
    }
    else {
        checkRes = false;
    }

    return checkRes;
}

I've also been checking for bit/byte order mismatches.  Here's what my TLV looks like in memory:

Thanks for any help!

  • I think I figured out the problems right after I posted.

    1. I read the TLV CRC incorrectly.  This line:

        UINT16 crcValue  = (*pCrcValueAddr << BYTE_SIZE_BITS) |
                *(pCrcValueAddr+1);

    needed to be replaced with

    UINT16 crcValue  = *pCrcValueAddr | (*(pCrcValueAddr+1)) << BYTE_SIZE_BITS;

    2. The value in the data sheet for the CRC end address, 0x1AF7, is correct.
    I replace this line:

    for (i = TLV_CRC_START; i < TLV_CRC_END; i += 2)

    with:

    for (i = TLV_CRC_START; i < 0x1AF7; i += 2)

    Hopefully this will be helpful for others...

**Attention** This is a public forum