ADuCM320 Hardware Reference Manual
UG-498
Rev. C | Page 77 of 196
The following code illustrates how the CRC is calculated and how to compare it to the result of the SIGN command.
int FeeCrc(int iLen,int *aiData)
{
int i1,i2,iCrc;
iCrc = 0xffffffff; //Seed value.
for(i1=0; i1<iLen; i1++) //Starting at lowest address.
{
for(i2=31; i2>=0; i2--) //MSB first.
{
iCrc <<= 1; //Left shift.
if((*(i1))&(1<<i2)) iCrc ^= 0x00800063; //^= Polynomial.
if(iCrc&(1<<24)) iCrc ^= 0x00800063;
}
}
return(iCrc&0x00ffffff); //Return 24 bits.
}
int FeeSign(unsigned long ulStartAddr, unsigned long ulEndAddr)
{
if((pADI_FEE->FEESTA&1)!=0) return 0;
pADI_FEE->FEEADR0 = ulStartAddr;
pADI_FEE->FEEADR1 = ulEndAddr;
pADI_FEE->FEEKEY = 0xF123F456;
pADI_FEE->FEECMD = 0x2;
return 1;
}
FeeSign(0x00800,0x00900); //SIGN for page1.
if(FeeCrc(511,(int *)0x00800) != pADI_FEE->FEESIG)
FlagError();
Else FlagSuccess();