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.

TMP126: About CRC function implement...

Part Number: TMP126

Hi Sir,

May I know how to implement the CRC function of TMP126?

Is there any application note for CRC function?

Thanks.

  • Hi Peter,

    Please find attached c code for the CRC implementation of the TMP126. I also included a snapshot of the CRC being verified with a datablock length of 2.

    tmp126-crc.c
    #include <stdio.h>
    
    void main(int argc, char *argv[]){
     unsigned short crc = 0xFFFF;
     unsigned int msg[20];
     int msglen = (argc > 1) ? (argc - 1) : 1;
     msg[0] = 0x0CE8;
     for (int i = 1; i < argc; i++){
      sscanf(argv[i], "%X", &msg[i-1]);
     }
     for (int byte = 0; byte < msglen; byte++){
      crc ^= msg[byte];
      printf("msgbyte: 0x%X\n", msg[byte]); 
      for (int bit = 0; bit < 16; bit++){
    //   printf("crc: 0x%X byte: %d bit: %d\n", crc, byte, bit);
       if (crc & 0x8000) 
        crc = (crc << 1) ^ 0x1021;
       else
        crc = (crc << 1);
      }
     }
     printf("crc: 0x%X\n",crc);
    }
    

    Jalen