Hi Champs,
My customer faced one issue on EtherCAT running in F2838x CM core. TX is working well, but RX has some problem. They found that F2838x receives the first data well from TwinCAT, but the next data are 16bit shifted.
They are suspicious of 8bit access of CM core in the following code. Could you help this issue?
/////////////////////// cia402appl.c//////////////////////////////////
void APPL_OutputMapping(UINT16* pData)
{
UINT16 j = 0;
UINT8 *pTmpData = (UINT8 *)pData; // get 8bit data point because CM only supports 8bit access
UINT8 AxisIndex;
for (j = 0; j < sRxPDOassign.u16SubIndex0; j++)
{
/*The Axis index is based on the PDO mapping offset (0x10)*/
AxisIndex = ((sRxPDOassign.aEntries[j] & 0xF0) >> 4);
switch ((sRxPDOassign.aEntries[j] & 0x000F))
{
case 0: //csp/csv RxPDO entries
{
TCiA402PDO1600 *pOutputs = (TCiA402PDO1600 *)pTmpData;
LocalAxes[AxisIndex].Objects.objControlWord = SWAPWORD(pOutputs->ObjControlWord); // objControlWord 16bit data, but only 8bit data is stored and 16bit is pushed back
LocalAxes[AxisIndex].Objects.objTargetPosition = SWAPDWORD(pOutputs->ObjTargetPosition);
LocalAxes[AxisIndex].Objects.objTargetVelocity = SWAPDWORD(pOutputs->ObjTargetVelocity);
LocalAxes[AxisIndex].Objects.objModesOfOperation = SWAPWORD((pOutputs->ObjModesOfOperation & 0x00FF));
/*shift pointer PDO mapping object following*/
if (j < (sRxPDOassign.u16SubIndex0 - 1))
{
pTmpData += SIZEOF(TCiA402PDO1600);
}
}
break;
///////////////////////////////////////////////////////////////////////
//////////////////////cia402appl.h////////////////////////////////////
/** \brief Data structure to handle the process data transmitted via 0x1600 (csp/csv RxPDO)*/
typedef struct STRUCT_PACKED_START
{
UINT16 ObjControlWord; /**< \brief Control word (0x6040)*/
INT32 ObjTargetPosition; /**< \brief Target position (0x607A)*/
INT32 ObjTargetVelocity; /**< \brief Target velocity (0x60FF)*/
INT16 ObjModesOfOperation; /**< \brief Mode of operation (0x6060)*/
}STRUCT_PACKED_END
TCiA402PDO1600;
///////////////////////////////////////