The project made use of a Kinetis KL05 Cortex-M0+ microcontroller running at 4MHz to control the Wiznet W5500 Ethernet module. The KL05 microcontroller communicates with the W5500 Ethernet module using SPI transfer protocol to send and receive data over TCP as a client. The device receives power from a micro-USB port.
Bottom view | Top view | |
The project made use of a Kinetis KL05 Cortex-M0+ microcontroller running at 4MHz to control the Wiznet W5500 Ethernet module. The KL05 microcontroller communicates with the W5500 Ethernet module using SPI transfer protocol to send and receive data over TCP as a client. The device receives power from a micro-USB port.
Schematic | PCB | |
The project was coded in assembly, broken up into multiple files. The file startup.s contains the code that is responsible for resetting the device, handling interrupts, and SPI communications. The w5500.s file contains code that manages the w5500 Ethernet module, including the procedures w5500_setup and Init_Socket which prepare the device by setting up RX and TX buffers and setup Socket 0 for TCP communication by loading the server and client information, Write_W500 and Read_W5500 which are used to control data transfer from the microcontroller to the Ethernet module, and TX_Data and RX_Data which are used to send data to the server (RX_Data) and receive data (TX_Data). The hardware.s file contains the code that is used to allocate space for flags and the SPI Buffer as well as initialize SPI0, the low power timer, the microcontroller’s ports, the system mode controller, and system’s clock.
The main code for the program is contained in the file main.s where a finite state machine is used to regulate TCP communications. The program loops, checking the status of the device first, then using the status to determine the next action. The program begins by establishing a connection to the server. After the connection has been established, the device sends an HTTP Get request to the server and receives a response in the form of an html page formed using PHP to extract information from the device’s Get Request. After the server sends the data to the device, the connection is closed and the device begins a five second countdown before establishing another connection to the server.
Through work on this project I have learned quite a bit about TCP communications and the communications protocols that are used to communicate between microcontrollers and peripheral devices. I have also expanded my knowledge and appreciation of assembly language programming. I plan to continue development of this project to allow the device to act as a server, sending temperature information to the client in a way similar to the way that the device presently communicates with the server when an interrupt is received.
Last modified:Mon, Jan 23, 2023.