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.

MSP430FR2355: Can I get a standard CRC16 example that verifies itself against the check value of a specific protocol?

Part Number: MSP430FR2355

I am having issues getting the CRC module to work. I don't need code review, just one example of the CRC in action returning a valid check value (the result of CRCing "123456789" without the null terminator) for whatever protocol it is implementing.

  • Once upon a time, long ago, I created code that would work three ways. With this helpful header:

    /*
      CRC routines.
    
      Some MSP430 devices have CRC hardware to help. That hardware produces
      results identical to this only if the data is written to the reverse
      bit order input register CRCDIRB. Results are in the normal bit order
      register CRCINIRES. Go figure.
    
      Two versions are available to trade space for time. The iterative and
      slower version is the default but a faster table version is used
      if CRCTABLE is defined. That requires a large (512 bytes) table.
    
      When compiled with "msp430-gcc -c -O2" the code size is:
    
      Table:     592
      Iterative: 120
      Hardware:   44
    
      If the target device has the CRC hardware then that is used. If the
      hardware is used the crc parameteris ignored. When hardware support is
      available all this file provides is the routine to process a string of
      data. If that isn't required, just use crc16.h and the macros will do
      the work.
    
      When tested with the usual test string of "123456789" all versions return
      0x29B1.
    
     */
    
    

  • Interesting, I did find and implement that little "double-reverse" requirement, but I am still having issues. What were your protocol parameters that yielded 0x29B1 so I have a base line and I can work from there to implement X25. 

  • just to clarify, is that a fully reflected bit stream or is that reverse bits, but the same byte-order?

  • You stuff data into CRCDIRB_L one byte at a time. In the order received.

    The Insert:Code editor thing is giving me trouble again so...

    Begin by initializing CRCINIRES to 0xffff.

    Write data bytes to CRCDIRB_L. 

    Read result from CRCINIRES.

  • Issue resolved, I am getting the checksum reflected as well, but I assume the quirkiness of this module means that is just how it is. 

  • Just for the record, Greg Cook has a list of a bunch of CRC algorithms with the results for "123456789" So you can see just what your algorithm does based on the generated checksum

    https://reveng.sourceforge.io/crc-catalogue/16.htm

**Attention** This is a public forum