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.

[FAQ] AM2634: MCAL Ethernet Polling and Interrupt mode

Part Number: AM2634

Hi experts,

I am using the out-of-box MCAL Eth app demo

  1. How do I disable interrupt pacing in my MCAL Ethernet project
  2. How do I switch to polling mode instead of interrupt mode.
  • In ethernet, two primary modes for handling data transmission and reception events are Polling and Interrupts.

    What is polling mode?

    In polling mode, the MCU periodically checks the status of transmission and reception. The R5F does not rely on the ethernet/DMA peripheral to notify it about new data being available (Rx) or data transmission being completed (Tx).

    What is interrupt mode?

    In interrupt mode, the MCU relies on the DMA to notify about the data transmission or reception. The DMA notify callback function is hit when new packets arrive (Rx flow). This callback function then handles the flow. On the Tx side, when the DMA completes the data transfer, the Tx callback will be hit which further handles the application flow.

    What is interrupt pacing?

    Interrupt pacing is a mechanism used to control the rate at which interrupts are generated in response to Rx and Tx events. This way, the resources are managed more efficiently. An interrupt pacing unit is used, for example 2ms, which indicates that interrupts will be generated every 2ms and all the packets will be handled in that time interval.

    Note: By default, the out-of-box MCAL Eth_App demo has Interrupt pacing enabled.

    Refer 4.10. ETH — Platform MCAL Development - AM263 User Guide (ti.com) to correctly get started and setup the Eth app demo

    Steps to disable interrupt pacing:

    1. Open your Eth configuration in EB tresos studio.
    2. In Eth, go to EthCtrConfig, double click on the index of your config, scroll to the EthCpdmaConfig and disable the EthRxInterruptPacingEnabeld and EthRxInterruptPacingEnabeld.
    3. Right click on the Eth config and generate the config files. The changes will be reflected in Eth_ConfigType_s.

    Steps to disable interrupts and enable polling:

    1. Open your Eth configuration in EB tresos studio.
    2. In Eth, go to EthCtrConfig, double click on the index of your config and disable the "EthCtrlEnableTxInterrupt" and "EthCtrlEnableRxInterrupt"
    3. Now right click on your project and generate the configuration files.
    4. In your examples_config folder, replace the Eth_Cfg.c and Eth_Cfg.h config files.
    5. Now in examples/Eth/EthApp.c file, call "Eth_TxConfirmation()" after the Eth_Transmit() function is called.

      retVal         = Eth_Transmit(pEthConfigPtr->ctrlIdx,
                                                bufIdx,
                                                frameType,
                                                txConfirmation,
                                                lenByte,
                                                gBCstMacAddr);
      #if (ETH_ENABLE_TX_INTERRUPT != STD_ON)           
                  AppUtils_delay(1U);
      #endif
                  if ((Std_ReturnType) E_NOT_OK == retVal)
                  {
                      gTestPassed = E_NOT_OK;
                      gAppObj.stats.ethTransmitErr++;
                  }
                  else
                  {
      #if (ETH_ENABLE_TX_INTERRUPT != STD_ON)
                      Eth_TxConfirmation(0);
      #endif
                      while(gAppObj.txConfirmPacketFlag==FALSE)
                      {
                        /*wait till tx packet confirmed */
                      }
                      gAppObj.stats.ethTransmitPckCnt++;

      A diff snippet for the same:
    6. Now clean and build the Eth_app demo (run the commands at: mcal_am263x_xx_xx_xx_xx/build folder)
      gmake -s allclean
      gmake -s eth_app
    7. Run the application using CCS. Open wireshark and check the packets transmitted from the microcontroller.

    8. Use a packet builder software (Colasoft, PackEth, Canoe etc) to build a packet and send to the MAC address of microcontroller. 
      Refer the AM26x academy for more information on networking tools: https://dev.ti.com/tirex/explore/node?node=A__AfKBUwO.x4eA8oN.qm.O6g__AM26X-ACADEMY__t0CaxbG__LATEST

    MCU sending packets to external world:

    MCU receiving packets from external world:

    As shown above, the Eth app demo will now use polling mode instead of the default interrupt mode.

    Regards,
    Shaunak