0 Members and 1 Guest are viewing this topic.
extern BYTE Buffer[5000];unsigned int DmaDoCrcExample(void){ unsigned int hwCrc; int chn=2; DmaTxferRes res; mCrcConfigure(0x11021, 16, 0xffff); res = DmaChnMemCrc(&hwCrc, Buffer, sizeof(Buffer), chn, DMA_CHN_PRI2); if(res!=DMA_TXFER_OK) return 0; // DMA calculation failed return hwCrc;}
Check that following things in PC code match your PIC setup: polynomial (there are other possibilities than 0x1021), initial value (some code uses 0, some 0xFFFF), final inversion - any difference in these things will produce different results.
UINT16 Calc_CRC_C_ARC(BYTE *Buff, UINT16 Len){ int i = 0; UINT16 crc = 0xFFFF; UINT counter = 0; UINT16 polynomial = 0xA001; for(counter=0; counter<Len; counter++) { for (i = 0; i < 8; i++) { BIT bit = ((Buff[counter] >> (7 - i) & 1) == 1); BIT c15 = ((crc >> 15 & 1) == 1); crc <<= 1; if (c15 ^ bit) crc ^= polynomial; } } crc &= 0xffff; return crc;}