Hi all,
I'm working with a TMP1827NNGRR. I'm accessing the one-wire bus through UART with a STM32G0B1. So far, everything is working great. I'm able to read temperature, configure the chip via Scratchpad-1, read/write to EEPROM withot any problem. Everywhere a CRC8 calculation is needed, for example when reading the Scratchpad-1, reading EEPROM, etc, my way of calculating the the CRC8 works just perfectly. The only issue I'm having is when I'm reading the 64-bit UID, which is composed of the bytes below (LSB to MSB), the CRC8 I'm calculating never matches the one received from the device :
1 byte device family
6 bytes address
1 byte CRC8, which is calculated from the 7 first bytes of the answer from the TMP1827.
The setup is a single device on the OW bus, bus powered 3.3V, 1Kohm PU resistor, controlled via UART, using standard speed (overdrive speed also works for everything else but this).
The sequence I'm using is :
1. Reset
2. (Write) Read address (0x33)
3. Read 8 bytes
4. Compute CRC8 using the 7 first bytes LSb first with the following code (which works with all the other CRC8 calculations)
uint32_t TMP18XX_Calculate_CRC8(const void *data, uint32_t len)
{
// Implementation processes LSB first with inverted polynomial to achieve same result.
const uint8_t *d = data;
const uint32_t ipoly = 0x0000008C; // Inverted 0x31
uint32_t crc = 0;
while(len--)
{
crc ^= *d++;
for(uint32_t k = 0; k < 8; k++)
{
crc = crc & 1 ? (crc >> 1) ^ ipoly : crc >> 1;
}
}
return crc;
}
Do you have any idea of what could be my problem here?
Thanks,
Alfred