AnsweredAssumed Answered

AD5421 PEC or CRC

Question asked by gonkelinx on Dec 28, 2014
Latest reply on Jan 6, 2015 by msamera

Hi,

 

i try to implement the PEC or CRC into the ad5421 with the following code.

 

#define CRC8_POLYNOMIAL_REPRESENTATION (0x07u) // x8 + x2 + x + 1

 

static u8 AD5421_ComputeCRC8(u8 * pBuf, u8 len)

{

  u8 i   = 0;

  u8 crc = 0;

 

  while(len)

  {

    for(i = 0x80; i != 0; i >>= 1)

    {

      if(((crc & 0x80) != 0) != ((*pBuf & i) != 0)) //MSB of CRC register XOR input Bit from Data

      {

        crc <<= 1;

        crc ^= CRC8_POLYNOMIAL_REPRESENTATION;

      }    else {

        crc <<= 1;

      }

    }

    pBuf++;

    len--;

  }

  return(crc);

}


When we send information to the DAC register the output change, so we assuming that the crc was correct.

But when we read the temperature or Vloop voltage, we receiving incorrect data.


When we now receive data from the AD5421, the crc wasn't more correct.

Ex: Received data  0xF0, 0x20, 0x73, 0xF0 from the ad5421 (the 0xF0 is the PEC byte)

                            0x9C we become from the AD5421_ComputeCRC8 procedure.


Is the function incorrect or is the Polynomial incorrect?

or is there anything else what we doing incorrect?


Who can help us to resolve this issue?


btw: everything works fine, reading and writing to other register when we not use the CRC


many thanks


Outcomes