Hey guys,
I'm trying to calculate some CRC-32 values using the TM4C129's CRC peripheral, but I'm running into some issues and I'm unable to get the peripheral to behave the way I'd like it to.
As a reference, I tried passing the ASCII string "Test" through two CRC utilities:
Online tool - http://www.lammertbies.nl/comm/info/crc-calculation.html
crcmod Python module - https://pypi.python.org/pypi/crcmod/1.7
Both of these tools generate a CRC-32 of 0x784DD132 from "Test", so these two are obviously doing the same calculation. My problem is that, regardless of how I've thought of configuring it, the TM4C129 CRC peripheral is not able to match the output from these tools.
Here's the snippet that I was testing with:
uint32_t delay = 40000000;
SysCtlPeripheralEnable(SYSCTL_PERIPH_CCM0);
SysCtlDelay(delay);
SysCtlPeripheralReset(SYSCTL_PERIPH_CCM0);
SysCtlDelay(delay);
uint8_t data[4] = {'T', 'e', 's', 't'};
uint32_t result;
CRCConfigSet(CCM0_BASE, CRC_CFG_SIZE_8BIT | CRC_CFG_ENDIAN_SBHW | | CRC_CFG_ENDIAN_SHW | CRC_CFG_TYPE_P4C11DB7 | CRC_CFG_INIT_0 | CRC_CFG_RESINV);
SysCtlDelay(delay);
result = CRCDataProcess(CCM0_BASE, (uint32_t *) data, 4, true);
Python's crcmod module can be configured in various ways, and its documentation said that for a regular CRC-32, you use a reversed algorithm with an initial value of 0 and XOR the output with 0xFFFFFFFF. It isn't clear what it means by a "reversed algorithm", so I tried OR'ing in all the combinations of CRC_CFG_OBR and CRC_CFG_IBR with the config macro I used. I also used the half-word and half-word byte swaps so the input would be big-endian. Here are the results:
None of the combinations mentioned above generated the same CRC as the reference tools. I'm guessing that my configuration of the peripheral is incorrect, but I've tried a pretty wide range of configurations and nothing seems to be working. If anyone could steer me in the right direction is would be greatly appreciated.
Thanks