This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具与软件:
您好!
如何计算不是64位倍数的数据的 CRC64? 例如、我想计算以下10字节数据的 CRC
DATA ={0x00、0x01、0x02、0x03、0x04、 0x07、0x08、0x90、0x12、0x13}
在 crcModConfig_t 结构中、我应该将 src_data_pat 和 data_length 字段设置为什么?
Ravi
Ravi
由于印度的排华节假日、敬请期待延迟回复。
此致、
Brennan
尊敬的 Ravi:
根据我的理解、CRC 压缩始终仅对64位数据进行。
如果要计算0x00、0x01和0x02的 CRC、则应提供0x000000000000、 0x000000000001和0x0000000000000002 。
因此、您可以按如下方式编写代码:
#include "HL_crc.h" uint64_t Data_Buffer[10] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x07, 0x08, 0x90, 0x12, 0x13}; uint8_t CRC_Completion_Flag = 0; crcConfig_t sCrcParams; uint64_t compressed_crc; int main(void) { crcInit(); Data_Initialization(); sCrcParams.crc_channel = CRC_CH1; sCrcParams.mode = CRC_FULL_CPU; sCrcParams.pcount = 0u; sCrcParams.scount = 0u; sCrcParams.wdg_preload = 0u; sCrcParams.block_preload = 0u; crcChannelReset(crcREG1, CRC_CH1); crcSetConfig(crcREG1, &sCrcParams); deneme.mode = CRC_FULL_CPU; deneme.crc_channel = CRC_CH1; deneme.src_data_pat = Data_Buffer; deneme.data_length = 10; crcSignGen(crcREG1, &deneme); compressed_crc = crcGetPSASig(crcREG1, CRC_CH1);/*Reading the compressed CRC from the CRC module*/ compressed_crc = swap_high32_with_low32(compressed_crc); /*Due to bug in crcGetPSASig the received CRC need to swap again* while(1); return 0; }
您无需提及更高的字节、在我们使用64位声明数组大小时、它会将更高的字节视为全零。
——
谢谢、此致、
Jagadish。