Part Number: AM2434
Hi experts,
we are observing some unexpected callback behaviour of the ethercat application.
We are developing on the LP-am243x launchpad, currently using the Ind Comms SDK 11.00.00.13.
Application Context
In our application, we set up a FreeRTOS Task to call the EtherCAT main loop periodically, using a task delay of currently 2ms. The task function looks like this:
for(;;)
{
EC_API_SLV_mainLoopCyclic();
vTaskDelay(2);
}
This task has a lower priority set as the PDI/Sync tasks.
We implemented our main application logic to read/write the PDO data in another function, which we registered to the stack via EC_API_SLV_cbRegisterUserApplicationRun().
The device is connected to a beckhoff PLC running twincat. The main ethercat task is running on a 1ms cycle time, and is set either to SM or DC synchronization mode.
The expected behaviour
According to your documentation and other E2E posts like this (https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1417335/am6442-ethercat-subdevice-stack-specify-trigger-of-application-function), we expect the application run callback to be called with a 1ms period, on both SM and DC sync modes.
On SM sync we expect it to be called from the PDI task, on DC sync we expect it to be called from the sync0 task. Either way, it should be independent from the main loop cycle time.
The observed behaviour
Using DC sync (with only sync0 enabled), we observe the expected behavour: Main loop is running with 2ms period due to the task delay, and the application run callback is called in the 1ms period.
However, the behaviour gets strange when switching to SM-sync mode:
Here, the application callback gets only called every 2ms.
We experimented with changing the EtherCAT cycle time as well as changing the main loop task delay time, and it seems like, in SM sync mode the application callback cannot be called faster than the main loop is running.
When changing the EtherCAT cycle time to be slower than the main loop cycle time, there is no difference between SM and DC sync, as expected.
Here is the result summarized:
| Sync Mode \ Settings | Main loop delay: 1ms EtherCAT cycle time: 1ms |
Main loop delay: 2ms EtherCAT cycle time: 1ms |
Main loop delay: 2ms EtherCAT cycle time: 4ms |
| DC-Sync | Callback period: 1ms | Callback period: 1ms | Callback period: 4ms |
| SM-Sync | Callback period: 1ms |
Callback period: 2ms | Callback period: 4ms |
Is in SM-sync the application run callback somehow depended on the main loop execution, and is this the expected behaviour?
Would be great to hear your insights on this!
Best regards
Stefan