Closed ClaudeMally closed 1 month ago
Hello, I found your wonderful library on github.
I looked at your checksum code and tried to adapt it for my code. This is what I came up with:
uint16_t mcp3x5xChecksum(const uint8_t* data, size_t length) { assert(data); const uint16_t initialValue = 0x0000; uint16_t crc = initialValue; for (size_t index=0; index < length; ++index) { crc = spi_mcp3x6x_AddCRC(crc, data[index]); } return crc; }
Then I fed in some data from my converter. and ran a small test
// (status, adcHigh, adcMiddle, adcLow, crcHigh, crcLow } const uint8_t readAdcBytes[] = {0x13, 0xd4, 0xef, 0xff, 0x10, 0xfe}; const size_t crcSize = sizeof(uint16_t); const size_t payloadSize = sizeof(readAdcBytes) - crcSize; const uint16_t payloadCrc = mcp3x5xChecksum(readAdcBytes, payloadSize); PRINTF("%s ", __func__); print_hex(readAdcBytes, payloadSize); PRINTF(" crc16=0x%04" PRIx16, payloadCrc); PRINTF(" versus 0x%02x %02x" NEWLINE, readAdcBytes[4], readAdcBytes[5]);
This is the output I got: testMcp3x5xChecksum 13 d4 ef ff crc16=0x1218 versus 0x10 fe
testMcp3x5xChecksum 13 d4 ef ff crc16=0x1218 versus 0x10 fe
Obviously 0x128 does not math 0x10fe
Note that I have enabled CRCCOM and my format is 16 bit (default)
I would have emailed the question directly but the only way to reach out to you (that I know about) is through github issues.
Questions: Did you test the CRCCOM functionality? I did not find that in your examples.
Problem was in the data I fed: there is no issue
Hello, I found your wonderful library on github.
I looked at your checksum code and tried to adapt it for my code. This is what I came up with:
Then I fed in some data from my converter. and ran a small test
This is the output I got:
testMcp3x5xChecksum 13 d4 ef ff crc16=0x1218 versus 0x10 fe
Obviously 0x128 does not math 0x10fe
Note that I have enabled CRCCOM and my format is 16 bit (default)
I would have emailed the question directly but the only way to reach out to you (that I know about) is through github issues.
Questions: Did you test the CRCCOM functionality? I did not find that in your examples.