On Mon, 04 Sep 2006 15:54:55 -0600, Dan Henry <usenet@danlhenry.com>
wrote:
>On 4 Sep 2006 12:17:28 -0700, "phesx" <phesx@libero.it> wrote:
>
>>Hi to all,
>>I have a problem with crc-8 dow algoritmic. x^8+x^5+x^4+1 CRC_DOW
>>
>>The problem is: I want implement the fast calculation but My
>>CRC_table is different from the CRC_DOWN table reported in the web
>>
>===SNIP===
>
>>question: someone can help me to understand my error?
>>do you think my problem could be related to reflaction or revers poly
>>or stuff like that?
>
>Yes, try the other way around:
>
>#include <stdio.h>
>
>#define POLY 0x8C
>
>void main(void)
>{
> int index;
> int i;
> unsigned x;
> unsigned temp;
>
> for (index = 0; index < 256; ++index)
> {
> temp = index;
>
> for (i = 0; i < 8; ++i)
> {
> x = temp & 1;
> temp >>= 1;
>
> if (x != 0)
> temp ^= POLY;
> }
>
> printf("0x%02X, ", temp);
> if ((index & 7) == 7) putchar('\n');
> }
>}
Please, ignore the "void main" stuff if you can. The important part
is the POLY and inner "for" loop.
--
Dan Henry
Reply by phesx●September 4, 20062006-09-04
thanks for your support Dan
Dan Henry ha scritto:
> On 4 Sep 2006 12:17:28 -0700, "phesx" <phesx@libero.it> wrote:
>
> >Hi to all,
> >I have a problem with crc-8 dow algoritmic. x^8+x^5+x^4+1 CRC_DOW
> >
> >The problem is: I want implement the fast calculation but My
> >CRC_table is different from the CRC_DOWN table reported in the web
> >
> ===SNIP===
>
> >question: someone can help me to understand my error?
> >do you think my problem could be related to reflaction or revers poly
> >or stuff like that?
>
> Yes, try the other way around:
>
> #include <stdio.h>
>
> #define POLY 0x8C
>
> void main(void)
> {
> int index;
> int i;
> unsigned x;
> unsigned temp;
>
> for (index = 0; index < 256; ++index)
> {
> temp = index;
>
> for (i = 0; i < 8; ++i)
> {
> x = temp & 1;
> temp >>= 1;
>
> if (x != 0)
> temp ^= POLY;
> }
>
> printf("0x%02X, ", temp);
> if ((index & 7) == 7) putchar('\n');
> }
> }
> --
> Dan Henry
Reply by Dan Henry●September 4, 20062006-09-04
On 4 Sep 2006 12:17:28 -0700, "phesx" <phesx@libero.it> wrote:
>Hi to all,
>I have a problem with crc-8 dow algoritmic. x^8+x^5+x^4+1 CRC_DOW
>
>The problem is: I want implement the fast calculation but My
>CRC_table is different from the CRC_DOWN table reported in the web
>
===SNIP===
>question: someone can help me to understand my error?
>do you think my problem could be related to reflaction or revers poly
>or stuff like that?
Yes, try the other way around:
#include <stdio.h>
#define POLY 0x8C
void main(void)
{
int index;
int i;
unsigned x;
unsigned temp;
for (index = 0; index < 256; ++index)
{
temp = index;
for (i = 0; i < 8; ++i)
{
x = temp & 1;
temp >>= 1;
if (x != 0)
temp ^= POLY;
}
printf("0x%02X, ", temp);
if ((index & 7) == 7) putchar('\n');
}
}
--
Dan Henry
Reply by phesx●September 4, 20062006-09-04
Hi to all,
I have a problem with crc-8 dow algoritmic. x^8+x^5+x^4+1 CRC_DOW
The problem is: I want implement the fast calculation but My
CRC_table is different from the CRC_DOWN table reported in the web
description:
looking at the web I've founf the CRC table to calculate CRC_DOW
(below an extract ... 0-15)
CRC_DOWN right table (decimal format):
0, 94, 188, 226, 97, 63, 221, 131, 194, 156, 126, 32, 163, 253, 31,
65, ................
My WRONG table is (decimal format):
0, 49, 98, 83, 196, 245 .........
In order to generate the CRC table I use the code below:
#define CRC8_POLYNOMIAL 0x131 // x^8+x^5+x^4+1 0001 0011 0001
CRC_DOW
int i, j;
unsigned int crc8;
for(i = 0 ; i < 256; i++){
crc8 = i;
for(j = 8; j > 0; j--){
if(crc8 & 0x80){
crc8 = (crc8 << 1) ^ CRC8_POLYNOMIAL;
}
else{
crc8 <<= 1;
}
}
//table[i] = crc8;
printf (" i ->%d; valore_d->%d valore_x->%
x\n\r",i,crc8,crc8);
}
question: someone can help me to understand my error?
do you think my problem could be related to reflaction or revers poly
or stuff like that?
thanks in advance
marco