AnsweredAssumed Answered

Calcul checksum CRC

Question asked by toxivirus_jon on Mar 6, 2014
Latest reply on Apr 21, 2014 by toxivirus_jon

Hello,

 

i'm trying to send data from arm to my dsp 21489 with SPI. First, I analyse the data sent by my ADUSB2Z adaptator, and reproduce it, bit per bit in a C code. The processor receive correctly the paramater sent and apply it. Now I would like to send other information and I'd like to calculate the CRC of my new message. Below, is my C code who doesn't actually work.

 

Code C

unsigned int pData[2]= {0};

unsigned int nSum = 0;

unsigned int nCRC = 0;

int nSizeBytes = 8;

int i =0;

 

 

pData[0]=0x00000005;

pData[1]=0x3A800000;

pData[2]=0x0000000C;

pData[3]=0x3F800000;

pData[4]=0x0000000D;

 

 

for (i = 0; i < nSizeBytes/4; i++)

{

          nSum += pData[i];

}

nCRC = ~nSum + 1;

 

 

printf("pdata1 = %u\npdata2 = %u\npdata3 = %u\npdata4 = %u\npData5 = %u \n\n",pData[0],pData[1],pData[2],pData[3],pData[4]);

printf("nSum : %u // nCRC : %u \n\n",nSum,nCRC);

When I try this code, and convert it in hexa in windows calc, it's not correct.

Somebody can help me ?

 

Thanks,

 

John

Outcomes