AD7779和AD7768的CRC的算法一样,应该是你的CRC函数写错了。下面的函数供参考:
#define AD7768_CRC8_POLYNOMIAL_REPRESENTATION 0x07
unsigned char AD7768_ComputeCRC8(unsigned long * pBuf, unsigned short bufSize)
{
unsigned long i = 0;
unsigned char crc = 0xFF;//***
while(bufSize)
{
for(i = 0x800000; i != 0x000000; i >>= 1)
{
if(((crc & 0x80) != 0) != ((*pBuf & i) != 0)) /* MSB of CRC register XOR input Bit from Data */
{
crc <<= 1;
crc ^= AD7768_CRC8_POLYNOMIAL_REPRESENTATION;
}
else
{
crc <<= 1;
}
}
pBuf++;
bufSize--;
}
return crc;
}
AD7779和AD7768的CRC的算法一样,应该是你的CRC函数写错了。下面的函数供参考:
#define AD7768_CRC8_POLYNOMIAL_REPRESENTATION 0x07
unsigned char AD7768_ComputeCRC8(unsigned long * pBuf, unsigned short bufSize)
{
unsigned long i = 0;
unsigned char crc = 0xFF;//***
while(bufSize)
{
for(i = 0x800000; i != 0x000000; i >>= 1)
{
if(((crc & 0x80) != 0) != ((*pBuf & i) != 0)) /* MSB of CRC register XOR input Bit from Data */
{
crc <<= 1;
crc ^= AD7768_CRC8_POLYNOMIAL_REPRESENTATION;
}
else
{
crc <<= 1;
}
}
pBuf++;
bufSize--;
}
return crc;
}
举报