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.

MSP430F6779A: Hardware CRC Generator

Part Number: MSP430F6779A
Other Parts Discussed in Thread: MSP430FG6626, MSP430WARE

Can someone here provide me the code implementation of MSP430F6779A hardware CRC-CCITT implementation. I tried lots of codes available online but none have them the CRC generated by MSP. Not sure whats going wrong. I want to use Hard CRC of MSP for redundacncy check at front end for which i am not getting the correct logic/code of CRC. Someone pplease guide me to write CRC code which matches exactly the CRC generated by the MSP CRC hardware. Thanks in advance.

  • Hello,

    Although not the same device, please check out the CRC code example associated with MSP430FG6626. Its the same CRC module and a similar family so porting the example should be easy. Its located in TI Resource Explorer in CCS or httP://dev.ti.com . Navigate to TI Resource Explorer -> Software -> MSP430Ware -> Devices -> MSP430F5xxx_6xx -> MSP430FG6626 -> Peripheral Examples -> Register Level -> msp430fg662x_crc16_01.c . It demonstrates the HW CRC and compares it to a SW version.
  • Hi I tried that already but it doesnt matches the result generated by MSP. My code for software CRC looks like below:-
    int main()
    {
    uint16_t crcvalue = 0xFFFF, i;
    uint8_t Arr[280] = {0};
    Arr[0] = 0xF7;
    Arr[1] = 0x01;
    Arr[2] = 0x0C;
    for(i=0;i<264;i++)Arr[i+3] = i;
    for(i=1;i<267;i++)
    {
    crcvalue = CCITT_Update(crcvalue, (uint16_t)Arr[i]); //Low byte as per example
    crcvalue = CCITT_Update(crcvalue,0); //High byte as per example
    }

    printf("crc value is %x", crcvalue);
    return 0;
    }

    // Software algorithm - CCITT CRC16 code
    unsigned short int CCITT_Update(unsigned short int init, unsigned short int input)
    {
    unsigned short int CCITT;
    CCITT =(unsigned char)(init >> 8)|(init << 8);
    CCITT ^= input;
    CCITT ^= (unsigned char)(CCITT & 0xFF) >> 4;
    CCITT ^= (CCITT << 8) << 4;
    CCITT ^= ((CCITT & 0xFF) << 4) << 1;
    return CCITT;
    }

    for above packet of UART data i mean Arr[1] to Arr[266] CRC, above code gives CRC as 0xBD01 while my MSP returns CRC as 0xA29F. Not getting what is going wrong. :(
  • Hello Gaurav,

    It seems you are not starting your for loop for the SW CRC at array position '0'. this could explain the difference. Make sure the bounds of what you are feeding into the HW CRC are matching what you are feeding the SW CRC.
  • Hi JH,
    That is intensional. I know and my hardware is also calculating same way only. I have just created a sample packet of the system where CRC is calculated after skipping first byte. Actually both side code is written by me only. i.e. MSP firmware and this application so no confusion in this case. It has to start from Arr[1] till Arr[266]
  • Gaurav,

    It seems your array is an array of characters, you need an integer array as this is a 16-bit CRC implementation. I'm guessing the HW here is pulling 16-bit at a time and if you are feeding it a char array, iI'm not sure what it would grab.
  • Hi JH,
    I found the problem. I was filling data to CRCDI register where as it is expected to be filled in CRCDIBR register. After making this change my CRC matches with software generated CRC. Thanks a lot for your help.

**Attention** This is a public forum