Skip to content

This MPLAB® X MCC example shows implementation of TCP/IP Lite Applications using Microchip ENCX24J600 Ethernet Driver on an AVR Device

License

Notifications You must be signed in to change notification settings

microchip-pic-avr-solutions/avr-tcpip-lite-encx24j600-solution

Repository files navigation

Microchip Technologies Inc.

TCP/IP Lite Solutions Using ENCX24J600 on ATtiny3217

This repository provides MPLAB® X IDE projects that will work out of the box with the hardware and software listed below. The solutions in the repository include functionalities for the User Datagram Protocol (UDP), Transmission Control Protocol (TCP) Server and TCP Client Demos. Note that the TCP/IP Lite stack needs to be serviced every one second and the timer callback function needs to be set to one second. Change the pin allocations for the Serial Peripheral Interface (SPI), Switch and LED if a different device is used.


Related Documentation

Hardware Used

Software Used

Hardware Used

More details can be found at the following links

Hardware Setup

  1. Place the ATtiny3217 Curiosity Nano Evaluation Kit on the Curiosity Nano Base.

  2. Connect the Serial Ethernet 2 Board to the mikroBUS™ 1 port on the Curiosity Nano Base and set the DIP switches according to the following connection diagram:
    Connection_Diagram

  3. The pins were set in MPLAB Code Configurator based on the available pins on ATtiny3217 Curiosity Nano.
    Hardware_Pin_Selection


UDP Solution

MPLAB X IDE
  1. Open the MPLAB X IDE. Connect the ATtiny3217 Curiosity Nano Evaluation Kit.

  2. From the downloaded projects, open encx24j600-udp-solution.X.
    Right click the project name and select Set as Main Project.
    Set encx24j600-udp-solution.X as main Project

  3. Open the Windows Command Prompt application on your PC. Type ipconfig to get the IP address of your PC.
    ipconfig

  4. Go to Source Files\App Files\src and open udp_demo.c. Under the function UDP_Demo_Initialize():

    • Modify the destination IP address with PC IP address as noted in Step 3
    • Modify the destination port (anything in the range of dynamic ports)
      destinationPort

  5. Go to Source Files\MCC Generated Files\tcpiplite\src\ and open udpv4_port_handler_table.c.

    • In UDP_CallBackTable[], add the following code to perform UDP Receive: {65531, UDP_Demo_Recv}.
      65531 is the port chosen in Step 4.
      udpReceive

  6. Launch Wireshark. From the Capture menu, click Options.
    Select an interface from the list to which your evaluation kit and PC are connected, click Start for capturing packets.
    Or select the respective interface on the start screen of Wireshark.
    E.g., Ethernet from the attached screenshot at Step 3 above.
    wiresharkDHCPCapture

  7. In Wireshark, set the filter field as dhcp||icmp and hit 'Enter' or click the arrow on the right end.
    wiresharkFilter

  8. Go back to MPLAB X IDE and click Make and Program Device to program the code to the device.
    destinationPort

  9. In Wireshark, check the DHCP packets to verify that the device is connected to the selected network. The handshake procedure will look as shown below:
    wiresharkDHCPCapture

  10. In Wireshark, click the “ACK” packet (or double click to open in new window). Expand “Dynamic Host Configuration Protocol” to get the device IP address.
    DHCPPacket


  1. Open the Java application TCPIP_Demo.exe. Go to the UDP tab and assign the same port number as udpPacket.destinationPortNumber in UDP_DEMO_Send().
    E.g., 65531 was chosen in Step 4.
    Click the Listen button. Click “Allow Access” if warning occurs. Assign the IP address of your evaluation kit which was found from Step 10.
    E.g., 10.14.5.112 from the attached screenshot in Step 10 above.
    Click the Claim button.
    udpDemoGUI-PortudpDemoGUI-IP

  1. In Wireshark, set the filter in the format dhcp||udp.port==65531 but with your chosen port number, 65531 in this example.
    wiresharkFilterUDP

  1. In Demo GUI, under UDP Send/Receive click the LED 1 to turn ON LED0 on the Curiosity Nano Evaluation Kit and observe the Wireshark capture.
    udpWireshark-LED_Packet

  1. In Demo GUI, inside the Send Data box type something (e.g., "Hello CNano").
    udpDemoGUI Send Data
    Click the Send button. Check the packet in the Wireshark capture.
    udpWireshark-Message_Packet

  1. Press the Switch SW0 on the Curiosity Nano Evaluation Kit. Check the packet in the Wireshark capture.
    udpWireshark-Received_Packet

🔝 Back to Top


TCP Client Solution

MPLAB X IDE
  1. Open MPLAB X IDE. Connect the ATtiny3217 Curiosity Nano Evaluation Kit.

  2. From the downloaded projects, open encx24j600-tcp-client-solution.X.
    Right click the project name and select Set as Main Project.
    Set encx24j600-tcp-client-solution.X as main Project

  3. Open the Windows Command Prompt application on your PC. Type ipconfig to get the IP address of the PC.
    ipconfig

  4. Go to Source Files\App Files\src and open tcp_client_demo.c from the project files. Under the function TCP_Client_Initialize():

    • Modify the remote IP address with PC’s IP address as noted in Step 3
    • Modify remote port (anything in the range of dynamic ports)
      tcpClient IP and Port Initialization

  5. Click the Make and Program Device to program the code to the device.
    destinationPort

  6. Open the Java application TCPIP_Demo.exe. Go to the TCP Server Demo tab and assign the same port as remoteSocket.port in TCP_Client_Initialize().
    E.g., 65534 chosen in Step 4.
    Click the Listen button.
    The status of the TCP connection is printed inside the STATUS text box.
    tcpClientSolutionGUI

  7. Launch Wireshark. From the Capture menu, click Options.
    Select an interface from the list to which your evaluation kit and PC are connected, click Start for capturing packets.
    Or select the respective interface on the start screen of Wireshark.
    E.g., Ethernet from the attached screenshot at Step 3 above.
    wireshark Handhsake

  8. In Wireshark, set the filter in the format dhcp||tcp.port==65534 but with the chosen port number instead of 65534.
    tcpWiresharkPacket

  9. After the connection is established, type some text inside the Send text box and click the Send button.
    The text sent is displayed inside the Sent/Received Data text box.
    tcpSend

  10. In Wireshark, keeping the same filter settings as in Step 8, check the TCP packets being sent from the PC to the Evaluation Kit.
    tcpWiresharkSend


  1. Click the Led 0 button inside the LED Control Field. This will turn on LED0 on the Curiosity Nano Evaluation Kit.
    tcpClientReceive_LED_State

  1. In Wireshark, keeping the same filter settings as in Step 8, check the TCP packets being sent from the Evaluation Kit to the PC.
    tcpClientWiresharkReceive

  1. Click the Disconnect button from the Demo GUI to close the TCP connection. Inside the STATUS text box a message will appear stating "Client Disconnected".
    tcp Demo GUI Client Disconnected

🔝 Back to Top


TCP Server Solution

MPLAB X IDE
  1. Open MPLAB® X IDE. Connect the ATtiny3217 Curiosity Nano Evaluation Kit.

  2. From the downloaded projects, open encx24j600-tcp-server-solution.X.
    Right click the project name and select Set as Main Project.
    Set encx24j600-tcp-server-solution.X as main Project

  3. Launch Wireshark. From the Capture menu, click Options.
    Select an interface from the list to which the HPC Development board and PC are connected, click Start for capturing packets.
    Or select the respective interface on the start screen of Wireshark.
    wiresharkDHCPCapture

  4. In Wireshark, set the filter field as dhcp||icmp and hit 'Enter' or click the arrow on the right end.
    wiresharkFilter

  5. Go back to MPLAB X IDE and click Make and Program Device to program the code to the device.
    destinationPort

  6. In Wireshark, check the DHCP packets to verify that the device is connected to the selected network. The handshake procedure will look as shown below:
    wiresharkDHCPCapture

  7. In Wireshark, click the “ACK” packet (or double click to open a new window). Expand the “Dynamic Host Configuration Protocol” to get the device IP address.
    DHCPPacket

  8. Open the Java application TCPIP_Demo.exe. Go to the TCP Client Demo tab.
    Assign the server IP address as the IP address noted from Wireshark in Step 7.
    Assign the port number as 7.
    Click the Connect button. The status of the TCP connection is printed inside the STATUS text box.
    tcpServerDemoGUI ConnecttcpServerDemoGUI Connected

  9. After the connection is established, type some text inside the Send text box and click the Send button.
    The text sent is echoed and displayed inside the Sent/Received Data text box.
    tcpServerSend

  10. In Wireshark, set the filter as dhcp||tcp.port==7
    Check the TCP packets being sent from the Evaluation Kit destined to the PC.
    tcpServerWiresharkSend


  1. Push the Disconnect button in the Demo GUI to close the TCP connection. Inside the STATUS text box a message will appear stating "Connection Closed".
    tcp Demo GUI Server Disconnecttcp Demo GUI Server Disconnected

🔝 Back to Top


Ethernet Drivers NPM TCP/IP Lite NPM

About

This MPLAB® X MCC example shows implementation of TCP/IP Lite Applications using Microchip ENCX24J600 Ethernet Driver on an AVR Device

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published