在运行下面程序后跑飞到illegal_isr()
UINT16 CiA402_Init(void)
{
UINT16 result = 0;
UINT16 AxisCnt = 0;
UINT16 j = 0;
UINT32 ObjectOffset = 0x800;
UINT8 PDOOffset = 0x10;
for(AxisCnt = 0; AxisCnt < MAX_AXES ; AxisCnt++)
{
/*Reset Axis buffer*/
HMEMSET(&LocalAxes[AxisCnt],0,SIZEOF(TCiA402Axis));
LocalAxes[AxisCnt].bAxisIsActive = FALSE;
LocalAxes[AxisCnt].bBrakeApplied = TRUE;
LocalAxes[AxisCnt].bLowLevelPowerApplied = TRUE;
LocalAxes[AxisCnt].bHighLevelPowerApplied = FALSE;
LocalAxes[AxisCnt].bAxisFunctionEnabled = FALSE;
LocalAxes[AxisCnt].bConfigurationAllowed = TRUE;
LocalAxes[AxisCnt].i16State = STATE_NOT_READY_TO_SWITCH_ON;
LocalAxes[AxisCnt].u16PendingOptionCode = 0x00;
LocalAxes[AxisCnt].fCurPosition = 0;
LocalAxes[AxisCnt].u32CycleTime = 0;
/***********************************
init objects
*************************************/
/*set default values*/
HMEMCPY(&LocalAxes[AxisCnt].Objects,&DefCiA402ObjectValues,CIA402_OBJECTS_SIZE);
/***set Object offset to PDO entries***/
/*csv/csp RxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sRxPDOMap0.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sRxPDOMap0.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/*csp RxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sRxPDOMap1.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sRxPDOMap1.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/*csv RxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sRxPDOMap2.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sRxPDOMap2.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/*csv/csp TxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sTxPDOMap0.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sTxPDOMap0.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/*csp TxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sTxPDOMap1.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sTxPDOMap1.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/*csv TxPDO*/
for(j =0; j < LocalAxes[AxisCnt].Objects.sTxPDOMap2.u16SubIndex0;j++)
LocalAxes[AxisCnt].Objects.sTxPDOMap2.aEntries[j] += AxisCnt* (ObjectOffset<<16);
/***********************************
init objects dictionary entries
*************************************/
LocalAxes[AxisCnt].ObjDic = (TOBJECT *) ALLOCMEM(SIZEOF(DefCiA402AxisObjDic));
HMEMCPY(LocalAxes[AxisCnt].ObjDic,&DefCiA402AxisObjDic,SIZEOF(DefCiA402AxisObjDic));
{
TOBJECT OBJMEM *pDiCEntry = LocalAxes[AxisCnt].ObjDic;
/*adapt Object index and assign Var pointer*/
while(pDiCEntry->Index != 0xFFFF)
{
BOOL bObjectFound = TRUE;
switch(pDiCEntry->Index)
{
case 0x1600:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sRxPDOMap0;
break;
case 0x1601:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sRxPDOMap1;
break;
case 0x1602:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sRxPDOMap2;
break;
case 0x1A00:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sTxPDOMap0;
break;
case 0x1A01:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sTxPDOMap1;
break;
case 0x1A02:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.sTxPDOMap2;
break;
case 0x603F:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objErrorCode;
break;
case 0x6040:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objControlWord;
break;
case 0x6041:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objStatusWord;
break;
case 0x605A:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objQuickStopOptionCode;
break;
case 0x605B:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objShutdownOptionCode;
break;
case 0x605C:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objDisableOperationOptionCode;
break;
case 0x605E:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objFaultReactionCode;
break;
case 0x6060:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objModesOfOperation;
break;
case 0x6061:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objModesOfOperationDisplay;
break;
case 0x6064:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objPositionActualValue;
break;
case 0x606C:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objVelocityActualValue;
break;
case 0x6077:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objTorqueActualValue;
break;
case 0x607A:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objTargetPosition;
break;
case 0x607D:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objSoftwarePositionLimit;
break;
case 0x6085:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objQuickStopDeclaration;
break;
case 0x60C2:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objInterpolationTimePeriod;
break;
case 0x60FF:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objTargetVelocity;
break;
case 0x6502:
pDiCEntry->pVarPtr = &LocalAxes[AxisCnt].Objects.objSupportedDriveModes;
break;
default :
bObjectFound = FALSE;
break;
}//switch(pDiCEntry->Index)
/*increment object index*/
if(pDiCEntry->Index >= 0x1400 && pDiCEntry->Index <= 0x1BFF) //PDO region
pDiCEntry->Index += AxisCnt* PDOOffset;
else
pDiCEntry->Index += AxisCnt* (UINT16)ObjectOffset;
pDiCEntry++;
}//while(pDiCEntry->Index != 0xFFFF)
}
}// for "all active axes"
return result;
}
Susan Yang:
请您私信/上传完整工程,我们来测试一下,谢谢
xiaomemg:
回复 Susan Yang:
我单步运行发现本应该顺序执行的程序它会自己陷入循环,很奇怪
Susan Yang:
回复 xiaomemg:
我这边是可以的。请问能具体说一下您是在那个语句会自己进入循环?
xiaomemg:
回复 Susan Yang:
UINT16 CiA402_Init(void)里面的HMEMSET(&LocalAxes[AxisCnt],0,SIZEOF(TCiA402Axis));
你加个断点会发现这个地方会执行好多次 按照程序应该是两次才对LocalAxes[AxisCnt].ObjDic = (TOBJECT *) ALLOCMEM(SIZEOF(DefCiA402AxisObjDic));
HMEMCPY(LocalAxes[AxisCnt].ObjDic,&DefCiA402AxisObjDic,SIZEOF(DefCiA402AxisObjDic));
在这两句分别加断点 你会发现会在这两个不断循环
Susan Yang:
回复 xiaomemg:
1 在您给出的工程中,下面的语句是被注释的
//HMEMSET(&LocalAxes[AxisCnt],0,SIZEOF(TCiA402Axis));2 这一句也是注释的
// CiA402_Init();请问您是参考哪个路径下的TI例程修改的?使用的是TI开发板(型号是什么)?
xiaomemg:
回复 Susan Yang:
在注释的后面有跟这个一样的函数开发板是28379d