Jul 31, 2019
08:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 31, 2019
08:27 PM
Hi Support team,
On DAP module TSv2.3, CRC-6 algorithm is not correct on section 1.8.3. We cannot get correct CRC value for transmitting packets. The result of function GetCrc cannot pass CRC Check at all.
Does anyone report similar issue?
Thanks!
On DAP module TSv2.3, CRC-6 algorithm is not correct on section 1.8.3. We cannot get correct CRC value for transmitting packets. The result of function GetCrc cannot pass CRC Check at all.
Does anyone report similar issue?
Thanks!
- Tags:
- IFX
5 Replies
Aug 01, 2019
01:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 01, 2019
01:33 AM
Here are the codes from the document:
const unsigned crc6Polynom =0x03; // x**6 + x + 1
unsigned CalcCrc(unsigned crcValue, unsigned thisbit) {
unsigned m = crcValue & crc6Polynom;
while (m > 0) {
thisbit ^= (m & 1);
m >>= 1;
}
return (((thisbit << 6) | crcValue) >> 1);
}
// obtain CRC6 for sending (6 bit)
unsigned GetCrc(unsigned crcValue) {
unsigned crc6 = 0; int i;
for (i = 0; i < 6; i++) {
crcValue = CalcCrc(crcValue, 0);
crc6 |= (crcValue & 0x20) | (crc6 >> 1);
crcValue &= 0x1F; // remove output bit
}
return (crc6);
}
// Calculate CRC6
for (i = 1; i < nDataBits; i++) { // Startbit excluded
thisBit = (unsigned)((telegram >> i) & 0x1);
crcValue = CalcCrc(crcValue, thisBit);
}
/* now send telegram + GetCrc(crcValue) */
// Check CRC6
unsigned crcValue = 0x3f;
int i;
unsigned thisBit;
for(i=1; i thisBit = (unsigned)((telegram>>i)&0x1);
crcValue = CalcCrc(crcValue, thisBit);
}
if(crcValue!=0) { /* put error handler here */ }
This is not the standard CRC6 algorithm. The issue is function GecCrc.
const unsigned crc6Polynom =0x03; // x**6 + x + 1
unsigned CalcCrc(unsigned crcValue, unsigned thisbit) {
unsigned m = crcValue & crc6Polynom;
while (m > 0) {
thisbit ^= (m & 1);
m >>= 1;
}
return (((thisbit << 6) | crcValue) >> 1);
}
// obtain CRC6 for sending (6 bit)
unsigned GetCrc(unsigned crcValue) {
unsigned crc6 = 0; int i;
for (i = 0; i < 6; i++) {
crcValue = CalcCrc(crcValue, 0);
crc6 |= (crcValue & 0x20) | (crc6 >> 1);
crcValue &= 0x1F; // remove output bit
}
return (crc6);
}
// Calculate CRC6
for (i = 1; i < nDataBits; i++) { // Startbit excluded
thisBit = (unsigned)((telegram >> i) & 0x1);
crcValue = CalcCrc(crcValue, thisBit);
}
/* now send telegram + GetCrc(crcValue) */
// Check CRC6
unsigned crcValue = 0x3f;
int i;
unsigned thisBit;
for(i=1; i
crcValue = CalcCrc(crcValue, thisBit);
}
if(crcValue!=0) { /* put error handler here */ }
This is not the standard CRC6 algorithm. The issue is function GecCrc.
Aug 02, 2019
03:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 02, 2019
03:03 AM
Got this issue solved. The CRC algorithm on document is TOTALLY wrong.
Aug 22, 2019
06:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Aug 22, 2019
06:40 AM
Hi Robinliuy,
may I ask you to share how you could solve this problem ?
I'm currently facing same issue. Impossible to pass the CRC6 check. I got the same C-Like code in my reference document.
Thanks in advance.
Best regards.
may I ask you to share how you could solve this problem ?
I'm currently facing same issue. Impossible to pass the CRC6 check. I got the same C-Like code in my reference document.
Thanks in advance.
Best regards.
Jan 29, 2024
03:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 29, 2024
03:40 AM
Dear User17829,
Please refer the following piece of code for your query.
#include <stdio.h>
#include <stdint.h>
const unsigned crc6Polynom = 0x03; // x**6 + x + 1
unsigned CalcCrc(unsigned crcValue, unsigned thisbit)
{
unsigned m = crcValue & crc6Polynom;
while (m > 0)
{
thisbit ^= (m & 1);
m >>= 1;
}
return (((thisbit << 6) | crcValue) >> 1);
}
// obtain CRC6 for sending (6 bit)
unsigned GetCrc(unsigned crcValue)
{
unsigned crc6 = 0;
for (int i = 0; i < 6; i++)
{
crcValue = CalcCrc(crcValue, 0);
crc6 |= (crcValue & 0x20) | (crc6 >> 1);
crcValue &= 0x1F; // remove output bit
}
return (crc6);
}
int main()
{
int i = 0;
/* Data: 0x55 LEN: 001000, CMD: 11010, Startbit: 1*/
uint32_t telegram = 0b01010101001000110101;
uint8_t nDataBits = 20 + 6; // Including crc bits
// uint32_t telegram = 0b1001011000111110101;
// uint8_t nDataBits = 19 + 6;
// uint32_t telegram = 0b0000001100001010010101;
// uint8_t nDataBits = 22 + 6;
// Calculate CRC6
unsigned crcValue = 0x3F;
for (i = 1; i < nDataBits; i++)
{ // Startbit excluded
unsigned thisBit = (unsigned)((telegram >> i) & 0x1);
crcValue = CalcCrc(crcValue, thisBit);
}
/* now send telegram + GetCrc(crcValue) */
printf("CalcCrc: 0x%02x\n", crcValue);
telegram = telegram | crcValue << nDataBits - 6; // CRC6 + Telegram
// Check CRC6
crcValue = 0x3F;
for (i = 1; i < nDataBits + 6; i++)
{ // No startbit, but with CRC
unsigned thisBit = (unsigned)((telegram >> i) & 0x1);
crcValue = CalcCrc(crcValue, thisBit);
}
if (crcValue != 0)
{ /* put error handler here */
printf("CRC Error\n");
}
}
Regards
ManojK
- Tags:
- aurix
Oct 29, 2021
12:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 29, 2021
12:01 AM
Dear sir,
i am also intersted in DAP.
could you please tell me where could find DAP module TSv2.3 ?
i could not search it from website.
thank you.