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.

DAC8741H: CRC

Part Number: DAC8741H

Hi

Trying to figure out the CRC for the DAC8741H. I know the polynomial is polynomial x8 + x2 + x + 1. Which i have interpret as a mask 0x87 is this correct?

What data bytes are included in the calculation? Is it just the data word or does it include the address + RW bit? Can somebody give an example of the CRC value for what i should expect to see for a packet that looks like:

0x820000

(Read command of the Control register to check CRC_EN bit is set)

Thanks

• Hi Ryan,

The mask would actually be 0x107.  Here is a snippet of code you can use to help calculate the CRC.

```unsigned int calculateCRC(unsigned int addr, unsigned int regdata){
unsigned int data[] = {addr,  ( (regdata & 0xff00) >> 8 ), regdata & 0xff};
static unsigned int len = 3;
unsigned int crc = 0x00;
size_t i, j;
for (i = 0; i < len; i++) {
crc ^= data[i];
for (j = 0; j < 8; j++) {
if ((crc & 0x80) != 0)
crc = (unsigned int)((crc << 1) ^ 0x107);
else
crc <<= 1;
}
}
return crc & 0xff;
```

My calculator shows that you would append 0xDD to your value.

0x820000DD.

Thanks,

Paul

• Hi Paul

Thanks, would you mind explaining why the mask is 16bit? I am quite confused as the largest order for the polynomial is 8.

Thanks

• Consider that the largest order is x^8, which could be written as 256.  The value 256 can only be represented with a 9 bit number.  so the polynomial is 'b 1 0000 0111.

• Perfect, makes sense. Thank you very much this has solved it.