1.2.5.3 ENCx24J600 Driver Library

The ENCx24J600 External MAC is an external module to the PIC32 that is connected through a SPI or PSP interface. This driver interfaces with the SPI driver to communicate with the external device to implement a complete Ethernet node in a system.

The following are some of the key features of this module:

  • Supports 10/100 Ethernet

    • Full-Duplex and Half-Duplex operation

    • Broadcast, Multicast and Unicast packets

    • Manual and automatic flow control

    • Supports Auto-MDIX

  • Fully configurable interrupts

  • Configurable receive packet filtering using:

    • 64-bit Hash Table

    • 64-byte Pattern Match

    • Magic Packet™ Filtering

    • Runt Packet Detection and Filtering

  • Supports Packet Payload Checksum calculation

  • CRC Check

  • Supports SPI interface

Abstraction Model

The ENCx24J600 Driver library has several different layers to it, as illustrated in the following figure. The interface layer has two main sections that are used the most often: The Tasks function, and the TCP/IP Send and Receive functions.

The Tasks function manages the internal state machine which detects, resets, and then configures the ENCx24J600 External MAC. It also handles the monitoring of the hardware status, sending and receiving packets.

The TCP/IP Send and Receive functions interact with the RAM-based queue of packets that are queued to send and packets that have been queued waiting for pick-up by the stack.

The main state machine does not interface directly to the SPI bus, but instead, interfaces to a virtual bus abstraction layer that allows for the replacement of the specific underlying bus implementation.

DRV ENCX24J600 Abstraction Model

Configuring the SPI Driver

The ENC hardware requires a specific configuration of the SPI driver to work correctly. Inside the MHC SPI Driver configuration be sure to select:

  • SPI clock rate of 14000000 or less. With a PB clock of 80 MHz, 13333333 is the clock rate.

  • Clock mode of DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL

  • Input phase of SPI_INPUT_SAMPLING_PHASE_AT_END

Recommended Settings

  • Interrupt Driver mode

  • Enhanced Buffer mode

  • DMA mode enabled:

    • DMA block transfer size of at least 1600 bytes

    • Size of DMA buffer for dummy data of at least 1600 bytes

    • Ensure when setting up DMA in interrupt mode that the DMA interrupts are a higher priority than the SPI Driver interrupt

SPI Configuration

Library Interface

NameDescription
System Interaction FunctionsFunctions
DRV_ENCX24J600_DeinitializeDeinitializes the ENCx24J600 Driver Instance.
DRV_ENCX24J600_InitializeInitializes the ENCx24J600 Driver Instance, with the configuration data.
DRV_ENCX24J600_ReinitializeReinitializes the instance of the ENCX24J600 driver.
DRV_ENCX24J600_TasksMain task function for the driver.
DRV_ENCX24J600_SetMacCtrlInfoThis function sets the MAC control information for the driver.
DRV_ENCX24J600_StackInitializeThis function initializes the driver with a TCPIP_MAC_INIT object.
DRV_ENCX24J600_ProcessAdditional processing that happens outside the tasks function.
Client Level FunctionsFunctions
DRV_ENCX24J600_CloseCloses a client handle to the driver.
DRV_ENCX24J600_ConfigGetGets the current configuration.
DRV_ENCX24J600_LinkCheckThis function returns the status of the link.
DRV_ENCX24J600_OpenThis function is called by the client to open a handle to a driver instance.
DRV_ENCX24J600_ParametersGetGet the parameters of the device.
DRV_ENCX24J600_PowerModeThis function sets the power mode of the device.
DRV_ENCX24J600_RegisterStatisticsGetGet the register statistics.
DRV_ENCX24J600_StatisticsGetRetrieve the devices statistics.
DRV_ENCX24J600_StatusGets the current status of the driver.
Receive FunctionsFunctions
DRV_ENCX24J600_PacketRxReceive a packet from the driver.
DRV_ENCX24J600_RxFilterHashTableEntrySetThis function adds an entry to the hash table.
Transmit FunctionsFunctions
DRV_ENCX24J600_PacketTxThis function queues a packet for transmission.
Event FunctionsFunctions
DRV_ENCX24J600_EventAcknowledgeAcknowledges an event.
DRV_ENCX24J600_EventMaskSetSets the event mask.
DRV_ENCX24J600_EventPendingGetGets the current events.
Data Types and ConstantsTypes
DRV_ENCX24J600_ConfigurationDefines the data required to initialize or reinitialize the ENCX24J600 Driver.
DRV_ENCX24J600_MDIX_TYPEDefines the enumeration for controlling the MDIX select.