Hi
I got the same problem when using f28377 to calculate CRC-16.
Moderator Note: Same problem is referring to https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/492359
Therefore, I use your source code and give same InputData for test.
Expecting to get 57B4 result, but the incorrect one.
//*****************************************************************************
// includes
//*****************************************************************************
#include "crc_tbl.h"
#include "vcu2_types.h"
#include "vcu2_crc.h"
#include "CrcTable0x1021.h"
#include "CrcTable0x8005.h"
#include "examples_setup.h"
//*****************************************************************************
// defines
//*****************************************************************************
// Filter Symbolic Constants
#define NUM_BYTES 19
//*****************************************************************************
// globals
//*****************************************************************************
#ifdef __cplusplus
#pragma DATA_SECTION("testInput")
#else
#pragma DATA_SECTION(testInput,"testInput")
#endif //__cplusplus
static const uint16_t testInput[NUM_BYTES] = {
0xA8, 0x01, 0x08, 0x2E, 0xE8,
0x2E, 0xD0, 0x2E, 0xF0, 0x2E,
0xE0, 0x2E, 0xE0, 0x2E, 0xE0,
0x2E, 0xE0, 0x2E, 0xE0
};
// \brief linker generated "run" location for the CRC table object
//
extern uint16_t crcTableRun;
// \brief linker generated "load" location for the CRC table object
//
extern uint16_t crcTableLoad;
// \brief linker generated "size" label indicating the size of the CRC table
// object
//
extern uint16_t crcTableSize;
// \brief object of the structure CRC_Obj
//
CRC_Obj CRC;
// \brief handle(pointer) to the CRC object
//
CRC_Handle handleCRC;
// \brief A single record(element) from the CRC table object
//
//
uint16_t pass = 0;
uint16_t fail = 0;
extern uint32_t testInputLoadStart, testInputLoadSize, testInputRunStart;
//*****************************************************************************
// protoypes
//*****************************************************************************
// Start of main()
void main()
{
// Locals
uint32_t crcResultC_1;
uint32_t crcResultVcu_1;
#ifdef FLASH
EALLOW;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0;
memcpy((uint32_t *)&RamfuncsRunStart, (uint32_t *)&RamfuncsLoadStart,
(uint32_t)&RamfuncsLoadSize );
VCU2_initFlash();
#endif //FLASH
VCU2_initSystemClocks();
VCU2_initEpie();
//*************************************************************************
// Example #1: 128 bytes(x8, even), parity: low byte first
//*************************************************************************
//! \b Example \b #1, \b Part \b 1
//! In this section we run a table lookup CRC on the vector testInput. The
//! table is specified in the header files "CrcTable0x8005.h" and
//! "CrcTable0x1021.h"respectively and the entries were generated from the
//! polynomials \f$ x^{16}+x^{15}+x^{2}+1 \f$ (CRC16 802.15.4, 0x8005) and
//! \f$ x^{16}+x^{12}+x^{5}+1 \f$ (CRC-CCITT, 0x1021) respectively.
//! The parity chosen was CRC_parity_even indicating that the CRC will start
//! from the low byte of the first word.
//! \code
//************************************************************************
// This is necessary since the section was declared within a UNION in the linker
// command file
memcpy((uint32_t *)&testInputRunStart, (uint32_t *)&testInputLoadStart,
(uint32_t)&testInputLoadSize );
// Step 1: Initialize the CRC object
CRC.seedValue = INIT_CRC16;
CRC.nMsgBytes = NUM_BYTES;
CRC.parity = CRC_parity_even;
CRC.crcResult = 0;
CRC.pMsgBuffer = (uint16_t *)&testInput[0];
CRC.pCrcTable = (uint16_t *)&crc16P2Table[0];
CRC.init = (void (*)(void *))CRC_init16Bit;
CRC.run = (void (*)(void *))CRC_run16BitTableLookupC;
// Step 2: Initialize the handle
handleCRC = &CRC;
// Step 3: Run the 16-bit table look-up CRC routine and save the first result
CRC.init(handleCRC);
CRC.run(handleCRC);
crcResultC_1 = CRC.crcResult;
//*************************************************************************
//! \endcode
//!
//! \b Example \b #1, \b Part \b 2
//! Now we run the VCU routine on the vector testInput. The two
//! polynomials employed by the VCU are fixed i.e.
//! \f$ x^{16}+x^{15}+x^{2}+1 \f$ (0x8005) and \f$ x^{16}+x^{12}+x^{5}+1 \f$
//! (0x1021) respectively
//! The parity chosen was CRC_parity_even indicating that the CRC will start
//! from the low byte of the first word.
//!
//! Most of the object elements remain unchanged from the initial setup
//!
//! \note The VCU routine does not require a lookup table; pCrcTable can be
//! reset to NULL or left as-is
//! \code
//*************************************************************************
// Step 1: Reset a few elements of the CRC object
CRC.crcResult = 0;
CRC.run = (void (*)(void *))CRC_run16BitPoly2;
// Step 2: Run the VCU 16-bit CRC routine and save the result
CRC.run(handleCRC);
crcResultVcu_1 = CRC.crcResult;
// Compare the results of steps 2/3 with 4/5
(crcResultC_1 == crcResultVcu_1)? pass++ : fail++ ;
//*************************************************************************
//!
//! \endcode
//!
//*************************************************************************
// End of test
done();
// Execution never reaches this point
return 1;
}
// End of main
// @} //addtogroup
// End of file
//###########################################################################
// End of File
//###########################################################################
Thanks!