1.1.3 EtherCAT LAN9255 Library

Ethernet for Control Automation Technology (EtherCAT) was developed by Beckhoff. EtherCAT is a fast and deterministic network, It processes data using dedicated hardware and software. It is based on a full duplex, manager(TwinCAT Manager)-client(LAN9255 Client) configuration.

The LAN9255 is a 2/3-port EtherCAT Client controller with dual integrated Ethernet PHYs which each contain a fullduplex 100BASE-TX transceiver and support 100Mbps (100BASE-TX) operation.
The EtherCAT LAN9255 Library contains a EtherCAT Client Controller Interface layer that enables Microchip MCUs to communicate with the LAN9255 EtherCAT Client controller. This interface layer supports different communication interfaces (QSPI (SPI/SQI mode), GPIO). The interface layer also serves as a Host peripheral bridge between the EtherCAT Beckhoff Client Stack Code (SSC) and the LAN9255. The SSC Stack (generated from standard SSC tool) contains features such as File over EtherCAT (FoE) and EEPROM Emulation for MCU firmware upgrade from TwinCAT tool.

EEPROM Emulation

In some system configurations the PDI (Processor Data Interface) is disabled, since much of the device is configured by the EEPROM contents. When EEPROM Emulation mode is used, the PDI configuration must be selected, as the EEPROM configuration data will be stored on the microcontroller’s internal memory. The microcontroller will configure the LAN9255 over the PDI interface and no external EEPROM device will be required to be connected to the LAN9255.

  • Hardware Configuration:
    EE_EMUL[2:0]PDI_SELECT
    0000x80 (SPI)
    0010x95 (HBI Indexed 16bit EtherCAT Direct Mapped)
    0100x91 (HBI Multiplexed 1 Phase 16-bit EtherCAT Direct Mapped)
    0110x93 (HBI Multiplexed 2 Phase 16-bit EtherCAT Direct Mapped)
    1000x82 (SPI EtherCAT Direct Mode)
    1010x05 (Beckhoff SPI Mode)
    110Unused
    111EEPROM is enabled
  • Software Configuration:

    Microchip provides ESF Demo code, which includes application files that support EEPROM Emulation, Configuration file (.xml) and Application file (.xlsx) are also provided.

    From the EtherCAT host’s point of view, there is no difference between EEPROM Emulation mode and I2C EEPROM, the host just issues EEPROM commands and wait until the EEPROM interface is no longer busy.

    Normally the ESI file that is loaded on the EEPROM, is generated using the SSC tool from Beckhoff. The EEPROM Emulation mode of the SSC tool must be configured for ESC EEPROM Emulation mode.
    EEPROM Emulation Configurations ParameterDescription
    ESC_EEPROM_EMULATIONIf set to 1, the EEPROM emulation is enabled and EEPROM commands are handled by the SSC.
    CREATE_EEPROM_CONTENTIf set to 1, then a header file including the EEPROM data according to the client configuration will be created during the client file generation process.
    ESC_EEPROM_SIZEAvailable EEPROM buffer size in Bytes.
    EEPROM_READ_SIZENumber of Bytes the ESC can handle on a single read access. For LAN9255, this value is 0x08
    EEPROM_WRITE_SIZENumber of Bytes the ESC can handle on a single write access. This value is always 2.

    For SSC tool EEPROM emulation ,select Hardware in Client Project Navigation Window and make sure ESC_EEPROM_SIZE is 0x800, ESC_EEPROM_EMULATION is 1 & CREATE_EEPROM_CONTENT is 0.

    SSC tool EEPROM Configuration:
    EtherCAT EEPROM Register AddressRegister Name
    0x140PDI Control Register
    0x141ESC Configuration Register
    0x150PDI Configuration Register
    0x151Sync/Latch PDI Configuration Register
    0x982:0x983Pulse Length of SyncSignals Register
    0x152:0x153PDI Extended Configuration Register
    0x0012:0x0013Configured Station Alias
    0x0510:0x0511MII Management Control/Status Register
    0x0142:0x0143ASIC Configuration
    Reserved 0x144:0x145Reserved

Features Supported

  • Supports the app_lan9255 EtherCAT Client Controller device.
  • Supports EEPROM Emulation.
  • Enables interfacing with different 32-bit microcontroller devices.
  • Contains File over EtherCAT and Trigger & Counter demonstration applications.
  • Demonstration applications are targeted for EVB-LAN9255-SAME53 Evaluation Board.
  • Demonstration applications are configured to use the SSC Error LED feature. This feature is implemented through the ERROR LED indicator on the board. When the ERRRO LED is ON, this indicates either of the following conditions:
    • EEPROM loading error
    • EtherCAT client connectivity link failure
    • Application Layer Event (AL Event) error indication
    • EtherCAT State mode transition error indication
  • The demonstration applications do not use the SSC Run LED feature.
  • Driver supports SPI Indirect, SPI Direct and Beckhoff SPI mode of Process Data Interface(PDI) selection.
    Process Data Interface ModeEEPROM Source Data Config
    SPI/SQI Indirect Mode0x80
    SPI/SQI Direct Mode0x82

    The EEPROM Source Data config data in the above table should be specified in the ESC CONFIG DATA attribute in the

    Microchip-SAME53-LAN9255-EtherCAT-Slave_SSC_Config_SPI_SQI_XXX_mode.xml file.

  • FoE (File Over EtherCAT) can be used to download and upload a file to an EtherCAT device. Bank Switch algorithm is used to switch the new firmware downloaded.
  • The LAN9255 SPI or SQI Client module provides a low pin count synchronous client interface that facilitates communication between the LAN9255 and the microcontroller. The SPI client provides the microcontroller access to the LAN9255 System Control and Status Registers, internal FIFOs and memories.

    The following is an overview of the functions provided by the LAN9255 SPI/SQI Client:

    • Serial Read: 4-wire (clock, select, data in and data out) reads at up to 30 MHz Serial command, address and data. Single and multiple register reads with incrementing, decrementing or static addressing.
    • Fast Read: 4-wire (clock, select, data in and data out) reads at up to 50 MHz Serial command, address and data. Dummy Byte(s) for first access. Single and multiple register reads with incrementing, decrementing or static addressing.
  • The Beckhoff Client Stack Code supports different modes of synchronization which are based on three physical signals: (PDI_)IRQ, Sync0 and Sync1.Both SM-Synchron and Distributed Clocks (DC) synchronization are supported.

LAN9255 Firmware Overview

  • drv_lan9255_ecat_util.c and drv_lan9255_ecat_util.h files are interfaced to Lan 9255 driver.
    NameSPI Different Mode API Description
    ECAT_InitializationInitialize the hardware interface (SPI) used to communicate with Client Controller
    ECAT_Lan9255_IsPDIFunctionalVerifies the hardware interface (SPI) is functional or not
    ECAT_Lan925x_SPIWriteInitiates an Indirect mode write transfer to Client Controller via selected PDI
    ECAT_Lan925x_SPIReadInitiates an Indirect mode read transfer to Client Controller via selected PDI
    ECAT_Lan925x_SPIFastReadInitiates an Indirect mode fast-read transfer to Client Controller via selected PDI
    ECAT_Lan925x_SPIReadPDRAMInitiates an Indirect mode read process data RAM transfer to Client Controller via selected PDI
    ECAT_Lan925x_SPIFastReadPDRAMInitiates an Indirect mode fast-read process data RAM transfer to Client Controller via selected PDI
    ECAT_Lan925x_SPIWritePDRAMInitiates an Indirect mode write process data RAM transfer to Client Controller via selected PDI
    ECAT_Lan9255_SPIWriteInitiates a direct mode write transfer to client Controller via selected PDI
    ECAT_Lan9255_SPIReadInitiates a direct mode read transfer to Client Controller via selected PDI
    ECAT_Lan9255_SPIFastReadInitiates a direct mode fast-read transfer to Client Controller via selected PDI
    ECAT_Lan9255_Beckhoff_SPIWriteInitiates a Beckhoff mode write transfer to Client Controller via selected PDI
    ECAT_Lan9255_Beckhoff_SPIReadInitiates a Beckhoff mode read transfer to Client Controller via selected PDI
    ECAT_ESCIRQInitializationInterrupt service routine initialization for the interrupt from EtherCAT Client Controller
    ECAT_SyncInterruptsInitializationSync0 and Sync1 Interrupt service routine Initialization
    NameSQI Different Mode API Description
    ECAT_Lan925x_SQIWriteInitiates an Indirect mode or Direct Mode SQI write transfer to Client Controller via selected PDI
    ECAT_Lan925x_SQIReadInitiates an Indirect mode or Direct Mode SQI read transfer to Client Controller via selected PDI
    ECAT_LAN925x_SQIWritePDRAMInitiates an Indirect mode SQI write process to Client Controller via selected PDI
    ECAT_Lan925x_SQIReadPDRAMInitiates an Indirect mode SQI read process data RAM transfer to Client Controller via selected PDI