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.
Hi,
I am using the TMS570 inbuilt Cyclic Redundancy Check Controller (CRC) Module to CRC 8 16-bit words of data. This takes some 3 microseconds (yes, 3us, I'm not joking).
I have tried similar code style for a straight checksum in a simple loop and this takes 1.9us (I still think that this is an age).
However, here is my code, am I using the CRC module interface correctly?
uint16 HwCrc_CalculateCrc16From32bit( const uint32 nCrcDataPtr[], const uint16_least nCrcLength, const uint16 nCrcStartValue)
uint16_least nIdx;
regCrc.CRC_CTRL2 = 0x00000000U; /* CRC Global Control Register 2 */
/* Write seed */
regCrc.PSA_SIGREGL1 = (uint32)nCrcStartValue; /* Channel 1 PSA signature low register */
regCrc.CRC_CTRL2 = 0x00000003U; /* CRC Global Control Register 2 */
/* Write each part of data block to PSA signature register */
for(nIdx = 0U; nIdx < nCrcLength; nIdx++)
{
regCrc.PSA_SIGREGL1 = (uint32)((uint16)nCrcDataPtr[nIdx]); /* Channel 1 PSA signature low register */
}
return (uint16)regCrc.PSA_SIGREGL1; /* Channel PSA signature low register contains the LS 32 bits of the answer. We are only taking the LS 16 bits */
}
Hi Tony,
This question has been forwarded to respective expert .
I'll get back to you as soon as I hear the response.
Best Regards,
Pratip
Thanks Pratip,
Since posting, I have spotted that I do not toggle the Channel 1 PSA Signature Register reset bit in CRC_CTRL0, so, for completeness, here is my latest code.
uint16 HwCrc_CalculateCrc16From32bit( const uint32 nCrcDataPtr[], const uint16_least nCrcLength, const uint16 nCrcStartValue)
uint16_least nIdx;
regCrc.CRC_CTRL0 = 0x00000001U; /* CRC Global Control Register 0 */
regCrc.CRC_CTRL0 = 0x00000000U; /* CRC Global Control Register 0 */
regCrc.CRC_CTRL2 = 0x00000000U; /* CRC Global Control Register 2 */
/* Write seed */
regCrc.PSA_SIGREGL1 = (uint32)nCrcStartValue; /* Channel 1 PSA signature low register */
regCrc.CRC_CTRL2 = 0x00000003U; /* CRC Global Control Register 2 */
/* Write each part of data block to PSA signature register */
for(nIdx = 0U; nIdx < nCrcLength; nIdx++)
{
regCrc.PSA_SIGREGL1 = (uint32)((uint16)nCrcDataPtr[nIdx]); /* Channel 1 PSA signature low register */
}
return (uint16)regCrc.PSA_SIGREGL1; /* Channel PSA signature low register contains the LS 32 bits of the answer. We are only taking the LS 16 bits */
}
I think the problem with speed is largely related to the for loop, but as I described, a checksum type addition within the loop instead of writing to PSA_SIGREGL1 was quicker.
Note that our team's original query on CRC was addressed by Frank Noha in post http://e2e.ti.com/support/microcontrollers/tms570/f/312/p/90947/319409.aspx#319409.
Regards, Tony.
Hi Enrique,
I'm using DMA now to drive my CRC so do not have this problem anymore. I haven't closed the post as, even thought I'm no longer interested, I thought TI might be interested in looking at it. If you want to close the post, then that's fine by me, bit I wouldn't regard it as answered.
Regards, Tony.
Hello all,
I have the same problem here. I use the similar ways of CRC function as Tony did initilally. And I need more than 10ms to calculate the CRC of data stocked in the 1M flash zone. The micro in use is TMS570ls2125.
Is there any other way instead of using DMA to get CRC more quickly?
Chengzhi,
The best way is to set up a 64 bit DMA transfer from memory to CRC registers. You can set up a DMA block transfer complete interrupt and check the CRC value after interrupt occurs. In the mean time, CPU can perform other tasks. If you really want to use CPU to do the work, you can try the attached assembly code .
Thanks and regards,
Zhaohong