Dear team:
One of my customer can read the position information of the motor encoder on the IDDKV2.2.1 evaluation board, but he found that check errors often occur. Is there any good way to deal with this?
The position is in the readTformatEncPosition program:
inline void readTformatEncPosition(void)
{
if(tFormat_dataId == PM_TFORMAT_DATAID3)
{
retVal1 = PM_tformat_receiveData(PM_TFORMAT_DATAID3);
crcResult = PM_tformat_getCRC(0, 80, 8,
(uint16_t *)(&tformatData.rxPkts), tformatCRCtable, 10);
crcResult = crcResult ^ (0xFF);
if(!tformat_checkCRC(crcResult, tformatData.crc))
{
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
tFormat_crcError = 1;
runMotor = MOTOR_STOP;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
//
//Invert the received bit sequence for position and
//turns for actual data
//
position =
((__flip32((uint32_t) tformatData.dataField0) >> 24 ) & 0xFF) |
((__flip32((uint32_t) tformatData.dataField1) >> 16 ) & 0xFF00) |
((__flip32((uint32_t) tformatData.dataField2) >> 8 ) & 0xFF0000);
turns =
((__flip32((uint32_t) tformatData.dataField4) >> 24 ) & 0xFF) |
((__flip32((uint32_t) tformatData.dataField5) >> 16 ) & 0xFF00) |
((__flip32((uint32_t) tformatData.dataField6) >> 8 ) & 0xFF0000);
tFormat_encCmdStatus = ENC_CLOSE;
tFormat_dataId = 0; // reset the ID log
Best regards