Part Number: TMS320F2800137
Other Parts Discussed in Thread: C2000WARE
我们想要使用TI提供的CRC32的计算方式,对于下边这个函数,我们使用TMS320F2800039芯片可以使用这个函数的得到CRC32的校验值,但是使用TMS320F2800137芯片使用这个函数的时候,仿真的时候可以进入到函数内部执行,但是得到的CRC32的校验值是0,查找芯片手册,没有找到关于这个的相关资料,在网上查找资料说,使用这个函数芯片内部需要有VCU模块,网上说039的有VCU模块,137的芯片没有这个模块,所以想问你们137是否有这个模块,使用这个函数是否需要这个模块,如果不需要的话,想问一下使用这个函数的话,需要的头文件vcu2_crc.h和vcu2_types.h两个芯片是否通用,请帮忙解释一下,谢谢!
Uint32 GetCRC32(Uint32 Flash_Addr_Start, Uint32 Length)
{
Uint16 i;
Uint16 q, r ;
Uint32 crcResult;
Uint32 Addr_Start, Addr_Length;
Addr_Start = Flash_Addr_Start;
Addr_Length = Length * 2;
// Step 1: Initialize the CRC object
CRC.pMsgBuffer = (uint16_t *)Addr_Start;
CRC.parity = CRC_parity_even;
CRC.crcResult = 0;
CRC.init = (void (*)(void *))CRC_init32Bit;
CRC.run = (void (*)(void *))CRC_run32BitTableLookupC;
CRC.seedValue = INIT_CRC32;
q = (uint16_t)((uint32_t)(Addr_Length & 0xFFFF0000) >> 16); // multiples of 65536
// Since we can do a max of 65535 bytes at a time, we need to add q
// to r to do the remainder
r = (uint16_t)((Addr_Length & 0x0000FFFF)) + q; // modulus 65535
// Step 2: Initialize the handle
handleCRC = &CRC;
// Step 3: Run the 8-bit table look-up CRC routine and save the result
CRC.init(handleCRC);
// Step 4: Reset a few elements of the CRC object
CRC.crcResult = 0;
CRC.run = (void (*)(void *))CRC_run32BitPoly1;
// Run the CRC for 65535 bytes q times
for(i = 0; i < q; i++)
{
//When CRC starts on low byte, it ends on a low byte, the next
// set of 65535 bytes must start with high byte of the last address
CRC.nMsgBytes = 0xFFFF; // 65535 bytes
CRC.run(handleCRC);
CRC.seedValue = CRC.crcResult;
CRC.parity ^= 1;
CRC.pMsgBuffer = (uint16_t *)(Addr_Start + ((i+1)*0x8000 - CRC.parity));// - CRC.parity
}
// Run the CRC on the remaining r bytes
CRC.nMsgBytes = r; // <= 65535 bytes
CRC.run(handleCRC);
crcResult = CRC.crcResult;
return crcResult;
}