Jump to content

Component: TCP/IP (ENC28J60) (Comms: Networking): Difference between revisions

From Flowcode Help
m Text replacement - "style="background-color:#EAE1EA; color:#4B008D;"" to "class="mtx-class-propfolder""
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
Line 713: Line 713:
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | TCP IP Specifics
| width="90%" class="mtx-class-propfolder" | TCP IP Specifics
|-
|-
Line 727: Line 727:
| colspan="2" | Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
| colspan="2" | Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | SPI Settings
| width="90%" class="mtx-class-propfolder" | SPI Settings
|-
|-
Line 766: Line 766:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | MAC Address
| width="90%" class="mtx-class-propfolder" | MAC Address
|-
|-
Line 800: Line 800:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | IP Address
| width="90%" class="mtx-class-propfolder" | IP Address
|-
|-
Line 824: Line 824:
| colspan="2" |  
| colspan="2" |  
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
Line 838: Line 838:
| colspan="2" | Decides how to perform the simulation of the component. TCP IP - Communicates using the Windows TCP IP communications DLL SPI / API - Communicates using the CAL SPI to allow the communications to be analysed and debugged. 
| colspan="2" | Decides how to perform the simulation of the component. TCP IP - Communicates using the Windows TCP IP communications DLL SPI / API - Communicates using the CAL SPI to allow the communications to be analysed and debugged. 
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | SPI Simulation
| width="90%" class="mtx-class-propfolder" | SPI Simulation
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix TSL
Version 2.2
Category Comms: Networking


TCP/IP (ENC28J60) component

A set of routines used to control a ENC28J60 TCP/IP Module. Required connections VCC, Reset, GND, SCK, MISO, MOSI, CS. Leave these pins disconnected CLKOUT, ENC_WOL, ENC_INT

Component Source Code

Please click here to download the component source project: FC_Comp_Source_TCPIP_ENC28J60.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_TCPIP_ENC28J60.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Here is a simple example to help get started with the ENC28J60 module.

The example program creates a web page server on the network and will also respond to ping requests.

The HTML to drive the web pages is included in the flowchart near the bottom of the main program loop.

ENC28J60 Example

Macro reference

CheckArpPacketIsMyreplyArp

CheckArpPacketIsMyreplyArp
 
- BYTE Return


CheckForARP

CheckForARP
Checks to see if the received data is an ARP request with my IP address. 
- UINT Length
 
- BYTE Return


CheckForIp

CheckForIp
Checks to see if the received data is an IP request with my IP address. 
- UINT Length
 
- BYTE Return


CheckForPing

CheckForPing
Checks to see if the received data is a Ping request 
- BYTE Return


CheckForTCPPort

CheckForTCPPort
Checks to see if the received data is requesting the server port 
- UINT Port
 
- BYTE Return


CheckForTCPType

CheckForTCPType
Checks to what kind of TCP type the received data is requesting. Returns a bit field specifying the type of request. 0x01 = Ack Requires, 0x02 = Synchronise 0x10 = Ack  
- BYTE Return


ClientSendPacket

ClientSendPacket
 
- UINT DestPort
 
- UINT SourcePort
 
- BYTE Flags
 
- BYTE MaxSegmentSize
 
- BYTE ClearSeqAck
 
- UINT NextAckNum
 
- UINT DataLength
 
- BYTE DestMac
 
- BYTE DestIp
 
- VOID Return


ControlLEDs

ControlLEDs
Allows both the LEDs on the Ethernet socket to be controlled. Useful for checking if the SPI communications are functioning correctly. 
- BYTE Mode
0=Off, 1=On, 2=Auto 
- VOID Return


FillTcpArray

FillTcpArray
 
- UINT Position
 
- UINT Count
 
- BYTE Data
 
- VOID Return


FillTcpData

FillTcpData
 
- UINT Position
 
- STRING Data
 
- UINT Return


GetDataLength

GetDataLength
Returns the number of received data bytes after the headers 
- UINT Return


GetModuleRevision

GetModuleRevision
Requets the module revision number and returns the value supplied by the module's firmware. 
- BYTE Return


GetSendersMAC

GetSendersMAC
Gets the MAC address from locations 6-11 of the IP Header 
- BYTE MAC
6-byte Array to store the MAC address 
- VOID Return


GetTcpDataPointer

GetTcpDataPointer
 
- UINT Return


Initialise

Initialise
Initialises the SPI connection to the TCPIP module and sets up some initial values. Flashes the LEDs on and off twice to confirm SPI comms are active. LEDs are then configured to auto functionality. 
- VOID Return


InitialiseDataLengthInfo

InitialiseDataLengthInfo
Initialises the data pointers to allow us to craft a response containing data 
- VOID Return


MakeArpAnswerFromRequest

MakeArpAnswerFromRequest
 
- VOID Return


MakeArpRequest

MakeArpRequest
 
- BYTE ServerIP
 
- VOID Return


MakeEchoReplyFromRequest

MakeEchoReplyFromRequest
 
- UINT Length
 
- VOID Return


MakeTcpAckFromAny

MakeTcpAckFromAny
 
- UINT Port
 
- VOID Return


MakeTcpAckWithData

MakeTcpAckWithData
 
- UINT DataLength
 
- VOID Return


MakeTcpSynackFromSyn

MakeTcpSynackFromSyn
 
- UINT Port
 
- VOID Return


PacketReceive

PacketReceive
Attempts to receive a data packet from the ENC28J60 module. Returns the number of bytes received. 
- UINT Return


PacketSend

PacketSend
Attempts to transmit a data packet to the ENC28J60 module. 
- UINT Length
 
- VOID Return


ReadArrayFromBuffer

ReadArrayFromBuffer
Reads an array of bytes from the buffer at location specified for the number of bytes specified. If a space character is encountered then the macro will return straight away without the space character in the string. 
- UINT BufferLocation
 
- BYTE NumberOfBytes
Number of bytes to read from the buffer and store into string 
- BYTE Data
 
- VOID Return


ReadRegister

ReadRegister
Reads the value from a single register onboard the ENC28J60 module. 
- BYTE Address
 
- BYTE Return


ReadStringFromBuffer

ReadStringFromBuffer
Reads a string from the buffer at location specified for the number of bytes specified. If a space character is encountered then the macro will return straight away without the space character in the string. 
- UINT BufferLocation
 
- BYTE NumberOfBytes
Number of bytes to read from the buffer and store into string 
- STRING Return


SetMyIPAddress

SetMyIPAddress
Allows the IP Address specified in the component properties to be overridden. The IP Address will revert back to the IP specified in the component properties as part of the initialise macro. 
- BYTE IP0
IP Address Parameter - e.g. 192 
- BYTE IP1
IP Address Parameter - e.g. 168 
- BYTE IP2
IP Address Parameter - e.g. 1 
- BYTE IP3
IP Address Parameter - e.g. 250 
- VOID Return


SetMyMACAddress

SetMyMACAddress
Allows the MAC Address specified in the component properties to be overridden. The MAC Address will revert back to the MAC specified in the component properties as part of the initialise macro. 
- BYTE MAC0
MAC Address Parameter 
- BYTE MAC1
MAC Address Parameter 
- BYTE MAC2
MAC Address Parameter 
- BYTE MAC3
MAC Address Parameter 
- BYTE MAC4
MAC Address Parameter 
- BYTE MAC5
MAC Address Parameter 
- VOID Return


WriteRegister

WriteRegister
Writes a value to a single register onboard the ENC28J60 module. 
- BYTE Address
 
- BYTE Data
 
- VOID Return


Property reference

Properties
TCP IP Specifics
Server Port
Sets the server's TCP/IP port address which is used to filter incoming TCP packets. 
Buffer Size
Number of bytes to use for the transmit and receive buffer, we actually use this +1 to allow for a null termination. 8-bit PICs should set this to 255 to allow compilation to succeed. Other devices can have larger buffers. Default = 500 
SPI Settings
Channel
SPI Channel selector 
Prescale
Prescale option selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
CS / SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Reset Pin
 
MAC Address
MAC0
 
MAC1
 
MAC2
 
MAC3
 
MAC4
 
MAC5
 
IP Address
IP0
 
IP1
 
IP2
 
IP3
 
Simulation
Label
 
Sim Type
Decides how to perform the simulation of the component. TCP IP - Communicates using the Windows TCP IP communications DLL SPI / API - Communicates using the CAL SPI to allow the communications to be analysed and debugged. 
SPI Simulation
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API