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.

TMAG5170-Q1: Start up Sequence and CRC

Part Number: TMAG5170-Q1
Other Parts Discussed in Thread: TMAG5170

Hi

There is no startup sequence mentioned in the data sheet.

Can you please provide the steps for the initializing the sensor?

And how about the CRC calculation? Shall I use the standard algorithm for CRC-4 bit?

Regards

Venkatesh

  • Hi Venkatesh,

    There isn't any sequencing that is needed to work with the TMAG5170. The sensor is integrated inside the chip and will ask you to refer to the datasheet to provide the requires voltage levels needed. 

    Also, can you please be more specific on the CRC request ? Is there any information presently not in the datasheet that can work here. section 7.5.2.5 does describe information on the CRC. 

  • Venkatesh,

    As Arjun pointed out, there's not a required initialization sequence for this device.  It just needs to have the appropriate channels enabled, configured for output, and triggered.

    The CRC polynomial for this device is X^4+X+1.  The CRC bits should be initialized to "1111" prior to starting the calculation.  We operate with 32 bits of data, but your input string will only be 28 bits long. You should pad the end of the 28 bit input with "0000" to force it to a total of 32 bits before performing the CRC calculation.  

    If you wish to disable the CRC check you can send the command x0F000407.  You should be able to check your CRC calculations against this command as well. (CRC result = b0111)

    Thanks,

    Scott

  • Hi Scott

    Thanks for your response.

    I have one more doubt.

    The first bit in the sequence is an MSB or LSB?

    Thanks,

    Venkatesh

  • MSB is first for TMAG5170

  • Hi Scott

    Do you have sample C code for accessing the registers?

  • Venkatesh,

    Sorry.  We do not yet have any code available to release as this device is still in a pre-release status.  The register format during read and write is as shown here:

  • Thanks for your response Scott.
    If the datasheet is updated with C codes, please let me know

  • Hi Scott

    I tried calculating the CRC for Data = 0x89000000 ( for reading X value) with the polynomial: 10011.

    My manual calculated value was 9.

    In my program, I initialized CRC with 0000 and i got the value as 9.

    But when I initialize CRC with 1111, i got the value as E.

    Which is the correct one? 

    Regards

    Venkatesh

  • Venkatesh,

    CRC should be initialized with 0b1111.  When parsing an input command 0x8900 0000 I get 0x0 as a result.

    It might be helpful to refer to this thread for more details

    https://e2e.ti.com/support/sensors/f/1023/t/937812

    Thanks,

    Scott

  • Hi Scottt

    Thank you. I have already gone through the thread that you have mentioned.

    The snippet in that thread was taken from the below website:

    [Edit: LINK updated]

    http://www.ghsi.de/pages/subpages/Online%20CRC%20Calculation/indexDetails.php?Polynom=10011&Message=89000000 

    Here as well I am getting the output as E for CRC initialized with 1111 and 9 when 0000 for my input 0x8900 0000 and poly: 0x13.

    I don't know why I didn't get 0 for this input.

    Regards

    Venkatesh

  • Venkatesh,

    Perhaps for some debug help you can refer to the calculations made after each step of the loop as shown in the table below.  CRC is initialized here as 0b1111. I've walked through the first step of the calculation for clarity.  This process should continue to step through the whole input word bit by bit and update the CRC bits through this process for each step.  After parsing the entire word, the last four bits (which are always passed into the function as 0b0000) will be replaced with the calculated CRC code.

    DoInvert should become '0' after an XOR between d[31]='1' and CRC[3]='1'.

    CRC[3] becomes '1' which is the value of CRC[2]

    CRC[2] becomes '1' which is the value of CRC[1]

    CRC[1] becomes '1' which is the value of CRC[0] XORed with DoInvert

    CRC[0] becomes '0' which is the value of DoInvert

    Bit INPUT Code CRC3 CRC2 CRC1 CRC0
    1 1 1 1
    31 1 1 1 1 0
    30 0 1 1 1 1
    29 0 1 1 0 1
    28 0 1 0 0 1
    27 1 0 0 1 0
    26 0 0 1 0 0
    25 0 1 0 0 0
    24 1 0 0 0 0
    23 0 0 0 0 0
    22 0 0 0 0 0
    21 0 0 0 0 0
    20 0 0 0 0 0
    19 0 0 0 0 0
    18 0 0 0 0 0
    17 0 0 0 0 0
    16 0 0 0 0 0
    15 0 0 0 0 0
    14 0 0 0 0 0
    13 0 0 0 0 0
    12 0 0 0 0 0
    11 0 0 0 0 0
    10 0 0 0 0 0
    9 0 0 0 0 0
    8 0 0 0 0 0
    7 0 0 0 0 0
    6 0 0 0 0 0
    5 0 0 0 0 0
    4 0 0 0 0 0
    3 0 0 0 0 0
    2 0 0 0 0 0
    1 0 0 0 0 0
    0 0 0 0 0 0
  • Hi Scott

    Thanks for your patience.

    I am able to see the logic is different from mine.

    The driver that I used:

    #include "stdio.h"

    int main()
    {
    int iCRC;
    int iPoly;
    int iByte;
    int iBit;
    iPoly = 0x13 << 3;
    iCRC = 0xF;
    int bText[4] = {0x89,0x00,0x00,0x00};
    for (iByte=0; iByte <4; iByte++){
    iCRC = iCRC ^ bText[iByte];
    for (iBit = 0; iBit < 8; iBit++){
    if ((iCRC & 0x80) != 0){
    iCRC = iCRC ^ iPoly;
    }
    iCRC = iCRC << 1;
    }
    }
    iCRC = iCRC >> 4;
    printf("CRC = %x", iCRC);
    return 0;
    }

    For CRC 0000, both the outputs are matching. For CRC 1111, since there is a mismatch how can i verify which is the correct one?

    Thanks,

    Venkatesh

  • Venkatesh,

    It looks like in your code you are setting operating with a byte at time, where the referenced code parses the word one bit at a time.

    The table I produced correctly follows the algorithm shown at the site you provided a link from.  It is important to consider that the CRC seed and the initial value in the input word are not the same.  You should initialize a 4 bit variable to track the CRC calculation starting with the value 0b1111. Setting this value to 0b0000 is incorrect. Instead, the 4 LSBs of the input word should be 0b0000. After completing the calculation, these 4 bits will be replaced with the CRC code you calculate.  Step through the entire 32 bit input word one bit at a time starting with the MSB, and perform the calculations based on this algorithm:

    INV = CRC[3] XOR DataBit                  //1

    CRC[3] = CRC[2]                                  //0

    CRC[2] = CRC[1]                                  //0

    CRC[1] = CRC[0] XOR INV                  //1

    CRC[0] = INV                                        //1

  • Thank you Scott.

    I shall step through one word at a time.

    Regards,

    Venkatesh