Hi,
i want to modify the EtherCAT API Demo for rcX V2 such that in the ESC interrupt the process data received from the master are written to the object directory. In the rcX V1 example, i simply passed the pointer to the task resources when setting up the ISR:
EcatHal_SetInterrupt(ptRsc->tRem.hEcatInterface,
ECAT_HAL_INT_SYNCMAN_CH_2, EcatSyncManCh2, ptRsc);
As such, inside the ISR i was able to modify OD objects, e.g.
if(ulEnableOuts) {
*(ptRsc->tRem.pwSTW) =
(TLR_UINT16)ulProcessBuffer;
}
In the rcX V2 example, the Sync Manager Handle is passed in parameter pvPrm to the ISR:
Esc_SetupInterrupt(ptRsc->tRem.hEcatInterface, ESC_INT_SYNCMAN_CH_2, EcatSyncManCh2,
Esc_GetSyncManagerHandle(ptRsc->tRem.hEcatInterface, 3));
Inside the ISR, pvPrm is not used explicitely. If i replace
Esc_GetSyncManagerHandle(ptRsc->tRem.hEcatInterface, 3)
by the resource pointer (ptRsc), the application hangs. I have to reload the application in order to continue.
How can i access my task resources inside the ISR? Is there any documentation for the Esc_XXX functions?
Hilscher Gesellschaft für Systemautomation mbH
Hi jr,
Create the particular object with the following: (based on a 607A example)
using memory provided by object dictionary:
uZero = 0x1234; // initial value
eRslt = Od2_CreateSubObject(hObjDict, OD2_ALLOC_OBJMGMT,
OD2_SENDER_NETWORK,
0x607A, 0, OD2_DIR_ALL,
ECAT_OD_WRITE_ALL|ECAT_OD_READ_ALL,
ECAT_OD_DTYPE_INTEGER16, 1, 0, 0, 0, &uZero);
if(eRslt == TLR_S_OK)
Od2_SetObjectName(hObjDict, 0x607A,"Target Position (truncated)");
This does not allow to access the memory easily from ISRs.
using memory provided by application:
ptRsc->tLoc.us607AValue = 0x1234; // initial valueeRslt = Od2_CreateSubObject(hObjDict, OD2_ALLOC_APP,
OD2_SENDER_NETWORK,
0x607A, 0, OD2_DIR_ALL,
ECAT_OD_WRITE_ALL|ECAT_OD_READ_ALL,
ECAT_OD_DTYPE_INTEGER16, 1, 0, 0, 0, &ptRsc->tLoc.us607AValue);
if(eRslt == TLR_S_OK)
Od2_SetObjectName(hObjDict, 0x607A,"Target Position (truncated)");
Now, the buffer used within the object dictionary is the one provided at the creation of the object. Now, you can implement your own synchronization scheme within the WriteCallback as well as the ISR. The object dictionary will use the memory provided by you.
Since the locking implemented in the object dictionary does not allow correct handling of accesses in all cases through its functions within ISRs (neither rcX V1 or rcX V2).
Greets,
code-small
Hi code-small,
the ESC ISR is set up in function
TaskResource_ExampleApp_InitRemote(EXAMPLE_APP_RSC_T FAR* ptRsc, TLR_VOID FAR* pvInit);
This is where ptRsc comes from. To transfer process data received from the EtherCAT master to the value storage, i still need the resource pointer ptRsc. As the ESC ISR has a parameter pvPrm which is not used so far, my idea was to use this parameter. Instead of
Esc_SetupInterrupt(ptRsc->tRem.hEcatInterface, ESC_INT_SYNCMAN_CH_2, EcatSyncManCh2,
Esc_GetSyncManagerHandle(ptRsc->tRem.hEcatInterface, 3));
i wrote
Esc_SetupInterrupt(ptRsc->tRem.hEcatInterface, ESC_INT_SYNCMAN_CH_2, EcatSyncManCh2, ptRsc);
But this modification causes my application to hang. Inside the ISR, i intended to access the resources in the following way:
void EcatSyncManCh2(RX_HANDLE hHandle, void FAR* pvPrm)
{
volatile TLR_UINT32 FAR* pbAddr;
TLR_UINT ulLen;
pbAddr=(volatile TLR_UINT32 FAR*)Esc_SmRequestBufferForReading(hHandle, &ulLen);
EXAMPLE_APP_RSC_T FAR* ptRsc = (EXAMPLE_APP_RSC_T FAR*)pvPrm;
...
} Hilscher Gesellschaft für Systemautomation mbH
Hi jr,
did you remove the following line inside EcatSyncManCh2 from the example?
EcatSyncManCh3(pvPrm, NULL);
It used the pointer as handle for Sm3 provided by the Esc_SetupInterrupt function.
Greets,
code-small
Hi code-small,
thanks a lot. I modified input data processing according to your hint and now it works.
code- small
Hilscher Gesellschaft für Systemautomation mbH
Hi jr,
since I do not see where the ptRsc comes from, I cannot see how to get things cleared up.
Did you change the code
Esc_SetupInterrupt(ptRsc->tRem.hEcatInterface, ESC_INT_SYNCMAN_CH_2, EcatSyncManCh2, Esc_GetSyncManagerHandle(ptRsc->tRem.hEcatInterface, 3));if you use pvPrm for ptRsc to
Esc_SetupInterrupt(ptRsc->tRem.hEcatInterface, ESC_INT_SYNCMAN_CH_2, EcatSyncManCh2, ptRsc);?
At the moment, I cannot see from where you get ptRsc inside the ISR. This would allow me to answer your question directly.
Greets,
code-small