Hi
I am struggling to get the TPS part to respond, and I believe that I am not calculating the CRC correctly. I have read the datasheet, and am out of ideas as to why it won't work. Here is an extract from the code.
The code calculates the CRC as each byte is send on the UART
#define CRC_POLY 0b00110001
putc(0x55); // Timing sync byte, not part of CRC
uint8_t crc = 0xFF; // Init CRC
delay_us(150);
putc(addr); // Send the device address, in this application 0x80 or 0x81
for (int j = 0; j < 8; j++) { // Calcuate the CRC on the first byte
if (crc & 0x01) {
crc = crc >> 1;
addr = addr >> 1;
crc = crc ^ CRC_POLY;
} else {
crc = crc >> 1;
addr = addr >> 1;
}
}
All thoughts appreciated!