This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM2434: AM243x-LP

Part Number: AM2434

Tool/software:

Hi there,
I wish to know how can the user add user code that will be called in EtherCAT interrupts. 
For your information, I see some APIs on this page: Interrupt management APIs for EtherCAT stack

Sync0Isr(), Sync1Isr(), EcatIsr() and EscCmdLowAckIsr(): are these APIs intended to be used by end user? 

Best regards,
Jinlong

  • Hi Jinlong,

    I wish to know how can the user add user code that will be called in EtherCAT interrupts. 
    • May I know what type of additional code you're trying to add?
    Sync0Isr(), Sync1Isr(), EcatIsr() and EscCmdLowAckIsr(): are these APIs intended to be used by end user? 
    • You can refer to the ISR definitions in source\industrial_comms\ethercat_slave\icss_fwhal\tiescbsp.c.
    • User can add user code to the ISRs but you will have to make sure that the addition doesn't affect other events as interrupt subroutines should be as short and fast as possible and additionally, increasing the size of ISR by adding code blocks can affect other tasks or interrupts which stays pending until the current ISR has been finished. So you will have to make sure that modifying the interrupt subroutines does not break other EtherCAT functionalities and proper stable EtherCAT communication is established.

    Regards,
    Aaron 

  • Q: Do you mean that TI does not provide ways to register callback such that a customer callback can be called in Sync0Isr() or Sync1Isr()? 
    Q: if the customer manually added callbacks in Sync0Isr() or Sync1Isr(), how can I rebuild the library? 

  • Q: Do you mean that TI does not provide ways to register callback such that a customer callback can be called in Sync0Isr() or Sync1Isr()? 
    • Customer can add their callbacks in Sync0Isr() or Sync1Isr(). It is dependent on the application usage. Be sure that the addition won't affect the overall functionality of EtherCAT.
    • By ways, do you mean guidelines? 
    Q: if the customer manually added callbacks in Sync0Isr() or Sync1Isr(), how can I rebuild the library? 
    • Once the additions are done in Sync0Isr() or Sync1Isr(), you can run "gmake -s -f makefile.am243x.r5f.ti-arm-clang" for Release build and "gmake -s -f makefile.am243x.r5f.ti-arm-clang PROFILE=debug" for Debug build. This needs to be run at /source/industrial_comms/ethercat_slave/icss_fwhal.

    Regards,
    Aaron

  • Follow-up: I wish to visualize interrupts to get a picture about when and which interrupts are are active. Could you give some instruction? 

    In addition, I wish to see CPU usage, memory consumption, and stack usage. Again, could you give me some instruction?

  • Hi Jinlong,

    Please expect a reply by mid next week for the follow-up requirements.

    Regards,
    Aaron

  • Hi Aaron, in spite of using Sync0Isr() in the SDK. It is possible to create an extra interrupt on sync0, in which user can call own functions, right?

  • It is possible to create an extra interrupt on sync0, in which user can call own functions, right?
    • Yes
  • Could you please share the details how to do that? 

  • Could you please share the details how to do that?
    • I'll check on this and get back to you if there's a guideline document recommended for such scenarios.

    Regards,
    Aaron

  • Hi Jinlong,

    I couldn't find an official guideline document for such scenarios.

    Couple of things to take care for such scenarios:

    1. If your user function needs to do complex operations, be cautious about stack overflow and the execution context within the PRU. Ensure that interrupt handling does not block critical timing or overload the available stack space.
    2. If your user function is blocking (i.e., it runs for a long time), consider managing interrupt priorities or queuing tasks instead of executing long operations directly in the ISR.
    3. If you need to handle more complex tasks, you can set a flag in the ISR and then process that flag in the main PRU loop (outside the interrupt context).
    4. Make sure that any modifications to the interrupt handling do not interfere with the timing or synchronization requirements of the EtherCAT protocol. The PRU often runs EtherCAT communication in a time-sensitive loop, so introducing significant delays or additional processing during SYNC0 interrupts could disrupt the EtherCAT data cycle.
    5. Ensure that your custom function does not introduce any latency or timing issues in the EtherCAT process by testing the implementation.

    You may provide the required functionality while maintaining system performance by effectively organizing your custom code and making sure the interrupt service routine stays lightweight.

    Regards,
    Aaron