Creating Wi-Fi® and Ethernet Applications Using MPLAB® Harmony Framework
- I. Introduction
- II. Getting Started
- III. Using MPLAB MHC plugin to import, configure modules and generate application templates
- IV. Adding code to the application template
- V. PC interface to interact with the PIC32 based TCP server
- VI. Adding Ethernet using MHC
- VII. Testing Your New Application
- VIII. Instructions for migrating this project
- IX. Troubleshooting
- Appendix A
I. Introduction
This article describes the process of creating a simple Wi-Fi® and Ethernet application on a PIC32MX microcontroller using the MPLAB® Harmony software framework. The concept is equally applicable when you want to add Wi-Fi and/or Ethernet functionality to an existing PIC32 Harmony project.
Reference Materials
- MPLAB® X Integrated Development Environment (IDE)
- MPLAB XC32/32++ Compiler
- MPLAB Harmony Embedded Software Development Framework
- MPLAB® Harmony Configurator (MHC)
- Tera Term
- Part Number: MA320003 PIC32MX795F512L Plugin Module
- Part Number: DM240001-2 Explorer 16/32 Development Board
- Part Number: AC164156 WINC1500 PICtail™ and PICtail PLUS Daughter Board
- Part Number: AC164132 Fast 100 Mbps Ethernet PICtail Plus Daughter Board
- Part Number: AC240100 PICtail Plus Expansion Board
- MPLAB REAL ICE™
- You may also use ICD3 or ICD4
Reference Documents
- Harmony Compiled HTML Help file: help_harmony.chm (located at C:\microchip\harmony\v2_04\doc\
- PIC32MX795F512L 100-pin to 100-pin TQFP CAN-USB Plug-in Module (PIM) Information Sheet
- WINC1500 PICTAILTM/PICTAIL PLUS Daughter Board User’s Guide
- Fast 100 Mbps Ethernet PICtail™ Plus Daughter Board User’s Guide
- Explorer 16 Development Board User’s Guide
Alternate Development Tools
If you do not have the specific tools listed above, you can study the process of configuring drivers in MHC as shown in this article, and port it to other combinations of development tools. For example:
II. Getting Started
You will implement a TCP server running on the PIC32 microcontroller which is connected to a local Wi-Fi network through the WINC1500 module in Bypass mode (i.e. using Harmony TCP/IP Stack instead of the on-board WINC TCP/IP Stack). At present, the Harmony driver for WINC1500 is only supported with FreeRTOS™ to maintain the non-blocking behavior of the Harmony framework. You will use the latest FreeRTOS version that is bundled with the Harmony installation. The “Application Templates” feature in Harmony provides a good base to build custom applications. You will use the TCP server template to write your code. Once Wi-Fi is working, you will extend this project by adding the Ethernet function to it.
III. Using MPLAB MHC plugin to import, configure modules and generate application templates
Create New Project
Complete the Harmony project details as shown in the image below.
You can keep the default Project Location in the applications folder or set a desired one as shown below.
Enter an appropriate 'Configuration Name'.
If there is no target board available for your microcontroller, leave it blank. It helps import respective board support packages.
Click on the Finish button to create a project which launches the MHC by default.
Configuring FreeRTOS
Under the MPLAB Harmony Configurator 'Options' tab, expand 'Third Party Libraries' and 'RTOS' trees:
- Check the 'Use RTOS?' box to enable it
- Set 'Select RTOS' to FreeRTOS
Select the first FreeRTOS option which is the latest version.
Expand the 'RTOS Configuration' tree:
- Set 'Tick rate (Hz)' to 1000
- Set 'Minimal stack size' to 512 bytes
- Set 'ISR stack size' to 512 bytes
- Set 'Memory management type' to Heap 2
- Set 'Total heap size' to 40960 bytes
Setting FreeRTOS Application Task(s)
Under the MHC 'Options' tab, expand the 'Application Configuration' tree:
- Set the 'Number of Applications' to 1
For now, you are creating only one application.
Expand the 'Application 0 Configuration' tree:
- Set the 'Application Name' to something meaningful (for example wnetcom)
This is your Wi-Fi network application.
- Enable 'Generate Application Code For Selected Harmony Components'
Expand TCPIP:
- Enable 'TCP Server: Transmit and Receive (same socket)'
If you want, change the TCP template parameters (port, text, etc.). Otherwise, keep them as default.
Under 'Application 0 Configuration' expand 'RTOS Configuration':
- Set 'Task Priority' to 2
- Enable 'Use Task Delay?' by checking the box
- Set 'Task Delay' to 1
Using Board Support Package (BSP)
Under 'Select BSP To Use For PIC32MX795F512L Device' check the 'PIC32MX795F512L PIM w\Explorer 16' box to enable it.
Setting FreeRTOS System Task
Expand the 'RTOS Configuration' tree:
- Set 'System Task Size' to 2048
- Set 'System Task Priority' to 3
- Enable 'Use System Task Delay?' by checking the box
- Set 'System Task Delay' to 1
At this point, you have configured a FreeRTOS system task a and FreeRTOS application task.
To achieve consistency with the Harmony structure without RTOS (i.e. a SYS_Tasks() super loop), MHC will provide you a choice to include further driver tasks as a part of a 'system task' or to be a 'standalone task'. You will set drivers and systems services as part of the 'system task' whereas the Wi-Fi driver has to be run as a 'standalone task'.
Debug and Reset System Services
The WINC1500 Wi-Fi driver uses the Debug system service to send logs to the console output.
Expand 'Debug':
- Enable 'Use Debug System Service?' by checking the box
- Set 'Debug Print Buffer Size' to 512
Expand 'Reset' system service:
- Check the 'Use Reset System Service?' to enable it if not already enabled.
Command and Console System Service
For any embedded project, it is important to have a way of printing messages to the console for debugging purposes. For this project, you will use the Harmony Command and Console System Service to send messages to a host computer using the UART module. The Explorer 16 board features a UART communication interface (Refer to the Explorer 16 User’s Guide).
Expand the 'Command' tree:
- Enable 'Use Command Processor System Service?' by checking the box
- Under 'RTOS Configuration', set 'Run Library Tasks As' to Combined with System Tasks
- Set 'Command Print Buffer Size' to 1024 bytes
Expand the 'Console' tree:
- Enable 'Use Console System Service?' by checking the box
- Set 'Select Peripheral for Console instance' to UART_CONSOLE
- Under 'RTOS Configuration (Instance 0)', set 'Run Library Tasks As' to Combined with System Tasks
In the following steps, you will be configuring the corresponding UART driver to work with the console service.
Under 'Harmony Framework Configuration' expand 'Drivers'.
The 'Use USART Driver?' module should already be enabled because of the previous step.
Expand 'USART Driver Instance 0':
- Under 'RTOS Configuration (Instance 0)', 'Run This Driver Instance As' to Combined with System Tasks
- Set 'USART Module ID' to USART_ID_2
This is because the Explorer 16 board UART2 is connected to the UART interface.
To complete UART driver configuration you will need to assign Tx/Rx pins for UART2 module. From the schematics (Refer to Explorer 16 Development Board User’s Guide), note that U2RX is pin-49 (RF4) and U2TX is pin-50 (RF5).
Go to MHC 'Pin Table' in MPLAB X IDE and click on the corresponding pin boxes:
or you can go to 'Pin Settings' tab and modify the function column for respective pins:
To revert, right click on module name>show> all.
Configuring TCP/IP Module:
Expand 'TCP/IP Stack' tree:
- 'Use TCP/IP Stack?' should already be enabled due to the TCP template configuration in Step 3.
Expand 'Use TCP\IP Stack?' tree:
- Under 'RTOS Configuration', set 'Run Library Tasks As' to Combined with System Tasks
Expand 'Network Configuration 0' tree:
- Set 'Interface' to WINC1500
- Enter a suitable 'Host Name' (for example: PIC32_WINC)
Sometimes there may be a conflict with pin assignments. You will need to un-assign them from the pin table first.
You can right click on module name in Pin Table and isolate them for a better view as shown above.
This will allow you to use the ping service.
The WINC1500 Wi-Fi driver uses Wi-Fi commands:
- Enable 'Use TCP/IP Commands':
- Check 'Enable Storage for Stack Commands'
- Check 'Enable Wi-Fi Related Commands'
Configuring Timer System Service and Timer Driver
At this point, you will need to configure corresponding drivers and services for the TCP/IP Stack. The TCP/IP Stack uses Timer System Service to keep track of all the timeout events. After looking at the Timer System Service, you will notice that it uses 'Timer Driver instance 0'. This means you will need to configure both Timer System Service and Timer Driver (which will be done in this Step). Also, since the PIC32 communicates to the WINC1500 module via an SPI interface on the Explorer 16 board, you need to configure two drivers: Wi-Fi (Step 10) and SPI (Step 12).
Under System Services >Timer:
- Under 'RTOS Configuration', set 'Run Library Tasks As' to Combined with System Tasks
- Check the 'Interrupt Notification Enabled' box
Under 'Harmony Framework Configuration':
- Expand 'Drivers'.
In Timer driver, MHC has detected a conflict. Expand it to see why.
Under 'TMR Driver Instance 0':
- Set 'Timer Module ID' to TMR_ID_2
- Under 'RTOS Configuration (Instance 0)', set 'Interrupt Priority' to INT_PRIORITY_LEVEL4
Configuring Wi-Fi Driver
Under 'Drivers':
- Disable 'Use Internal Ethernet MAC Driver?' by unchecking the box
Under the 'Wi-Fi' driver:
- Enable 'Use Wi-Fi Driver?'
- Set 'Wi-Fi Device' to WINC1500
- Under 'RTOS Configuration', ensure that 'Run Wi-Fi Driver RTOS Task' is set to Standalone
- Ensure 'Wi-Fi Network Type' is set to Infrastructure which means you will connect the WINC1500 to an existing Wi-Fi network
- Enter the 'Wi-Fi SSID' in the space provided or indicated by <Your Wi-Fi Name> in the image below
- Set 'Wi-Fi Security Mode' to your security mode
- Enter the 'Wi-Fi WPA-PSK' or 'WPA2-PSK Pass Phrase' in the space provided or indicated by <Your Wi-Fi Password> in the image below
Set WINC1500 Pin Port Channels and Pin Bit Positions
You can determine the Pin Port Channels and Pin Bit Positions by examining Appendix A-1. The WINC1500 to PIC32 connections are shown in the table below:
WINC1500 pin | PIC32 Pin Port | PIC32 Pin Bit |
---|---|---|
Chip Enable | F | 1 |
Reset | F | 0 |
Interrupt | E | 8 (INT10) |
SPI Clock | D | 10 (SCK1) |
SPI Data IN | D | 0 (SDO1) |
SPI Data OUT | C | 4 (SDI1) |
SPI Slave Select | D | 9 (SS1) |
Go to the Harmony 'Pin Settings' tab and change 'Function' for pin number 87 (RF0) and 88 (RF1) to GPIO_OUT. These two pins are Reset and Chip Enable. You will set the SPI pins later in Step 12.
Setting External Interrupt System Services
Go to System Services > Interrupts:
- Enable 'Use External Interrupts?' by checking the box
External interrupts will be used by the Wi-Fi driver.
Ensure 'External Interrupt Instance 0' is enabled:
- Set 'External Interrupt Module ID' to INT_EXTERNAL_INT_SOURCE_1
This will connect the WINC1500 interrupt pin to the PIC32 INT1 pin.
- Enable 'Generate ISR Code?' :
- Set 'Interrupt Priority' to INT_PRIORITY_LEVEL3
- Set 'Interrupt Sub-priority' to INT_SUBPRIORITY_LEVEL1
- Set 'Polarity' to INT_EDGE_TRIGGER_FALLING
In the Pin Table:
- Assign pin 18 (RE8) to the External Interrupt 1 module.
Configuring SPI Driver:
You will be using the SPI driver in interrupt mode.
Enable 'Use Interrupt Mode?' by checking the box
Under 'SPI Driver Instance 0':
- Set 'RTOS Configuration (Instance 0)' to Combined with System Tasks
- Set 'SPI Module ID' to SPI_ID_1
- Enable 'Driver Mode' by checking the 'Interrupt Mode' box (This should resolve the SPI issue.)
- Set 'Clock Mode' to DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL
- Set 'Dummy Byte Value' to 0x00
In the Pin Table, assign SPI1 (SPI_ID_1) pins as:
- SCK1 = pin 70 (RD10)
- SDI1 = pin 9 (RC4)
- SDO1 = pin 72 (RD0)
- SS1 = pin 69 (RD9).
Complete the MHC Configuration
In the Generate Project window ,select desired merging strategy and click Generate.
You will notice several source files and header files created in the project window.
- main.c file has the generic state machine while loop.
- wnetcom.c file is your application file where you will be writing and updating code.
All the variable and state names will be coherent with your application name defined in Step 3.
IV. Adding code to the application template
In this section you will write a simple LED toggle application that receives commands from the Tera Term terminal emulation program which acts as a TCP Client.
In the wnetcom.c file (under Source Files > app >), you will notice that MHC has generated a basic TCP server template for you. The three functions are:
- void WNETCOM_Initialize (void)
- void WNETCOM_Tasks (void)
- static void TCP_Server_TXRX_Task (void)
The basic flow of the project is as follows:
- Check if TCP/IP Stack is successfully initialized. Proceed after successful initialization.
- Check the number of available network interfaces. (in our case, it’s only 1: Wi-Fi)
- Wait till the interface receives a valid IP address from the DHCP server.
- After receiving a valid IP, open a TCP server socket on the specified port.
- Wait for incoming connection from a TCP Client.
- After receiving a TCP Client connection, send the greeting “Hello Client!”
- Wait for any messages from the client and parse them. Toggle LED on Explorer 16 board if a valid message is received.
- Keep checking the connection continuously.
- Notify when the client disconnects.
- Go back to step (5).
API functions used are:
(You can read their description in C:\microchip\harmony\v2_04\doc\help_harmony.htm file)
- TCPIP_STACK_Status()
- TCPIP_STACK_NumberOfNetworksGet()
- TCPIP_STACK_IndexToNet()
- TCPIP_STACK_NetAddress()
- TCPIP_STACK_NetIsReady()
- TCPIP_TCP_ServerOpen()
- TCPIP_TCP_ArrayPut()
- TCPIP_TCP_GetIsReady()
- TCPIP_TCP_ArrayGet()
By referring to the code flow above and the API functions, analyze the application structure. Let’s start adding code to your application file. (Line numbers in the images are for reference only and may vary in your project).
In the WNETCOM_Tasks() function and WNETCOM_STATE_INIT state, Change the appInitialized declaration to false.
bool appInitialized = false;
If TCPIP_STACK_Status() returns a negative value, notify the user that TCP Stack Initialization has failed. You will use the console service API to send formatted strings to the serial terminal.
Make sure you put console print statements before state variable changes in the code. Otherwise, the logs may be confusing!
SYS_CONSOLE_PRINT("WNETCOM[%d]: TCP/IP stack initialization failed!\r\n", wnetcomData.state);
Add these lines to set appInitialized equal to true when the TCP/IP Stack becomes ready and display a message.
appInitialized = true;
SYS_CONSOLE_PRINT("WNETCOM[%d]: TCP/IP stack initialized!\r\n", wnetcomData.state);
Add another console message while exiting the WNETCOM_STATE_INIT state.
SYS_CONSOLE_PRINT("WNETCOM[%d]: Application initialized!\r\n", wnetcomData.state);
At this point, the function WNETCOM_Tasks() enters state WNETCOM_STATE_SERVICE_TASKS where it is executing TCP_Server_TXRX_Task() continuously. This function maintains its own state machine to handle the TCP server.
In the WNETCOM_STATE_INIT state, set the TXRX state machine in WNETCOM_TCPIP_WAIT_FOR_IP after TCP/IP Stack state becomes SYS_STATUS_READY. Change the TXRX function code in the WNETCOM_TCPIP_WAIT_FOR_IP state as follows:
case WNETCOM_TCPIP_WAIT_FOR_IP:
{
// Check if the IP address of an interface has changed
wnetcom_nNets = TCPIP_STACK_NumberOfNetworksGet();
for (i = 0; i < wnetcom_nNets; i++)
{
wnetcom_netH = TCPIP_STACK_IndexToNet;
ipAddr.Val = TCPIP_STACK_NetAddress(wnetcom_netH);
if (dwLastIP[i].Val != ipAddr.Val)
{
dwLastIP[i].Val = ipAddr.Val;
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: IP Address: ", wnetcomData.txrxTaskState);
SYS_CONSOLE_PRINT("%d.%d.%d.%d \r\n", ipAddr.v[0], ipAddr.v[1],
ipAddr.v[2], ipAddr.v[3]);
if (ipAddr.v[0] != 0 && ipAddr.v[0] != 169) // Wait for a Valid IP
{
wnetcomData. txrxTaskState = WNETCOM_TCPIP_OPENING_SERVER;
}
}
}
}
break;
Once a valid IP Address is received, proceed to open a TCP server. Add a couple of console statements to WNETCOM_TCPIP_OPENING_SERVER state for checking (code locations as shown in image below).
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: Couldn't open server socket\r\n", wnetcomData.txrxTaskState);
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: Waiting for Client Connection on port: %d\r\n",
wnetcomData.txrxTaskState, wnetcomData.port);
Wait till you receive a connection. You can implement a timeout here using a Timer if you want. Send a greeting to the client and change state to wait for client response in the state WNETCOM_TCPIP_WAIT_FOR_CONNECTION.
SYS_CONSOLE_MESSAGE("WNETCOM: Received a connection\r\n");
Modify WNETCOM_TCPIP_WAIT_FOR_RESPONSE state so that if connection is closed, state will be changed to WNETCOM_TCPIP_WAIT_FOR_CONNECTION. If data is received from the client, parse it and add logic for toggling LED’s.
case WNETCOM_TCPIP_WAIT_FOR_RESPONSE:
{
if (!TCPIP_TCP_IsConnected(wnetcomData.socket))
{
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: Connection closed/lost\r\n", wnetcomData.txrxTaskState);
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: Waiting for Client Connection on port: %d\r\n",
wnetcomData.txrxTaskState, wnetcomData.port);
wnetcomData.txrxTaskState = WNETCOM_TCPIP_WAIT_FOR_CONNECTION;
break;
}
if (TCPIP_TCP_GetIsReady(wnetcomData.socket))
{
TCPIP_TCP_ArrayGet(wnetcomData.socket, wnetcomMsgFromClient, sizeof(wnetcomMsgFromClient) - 1);
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: Client sent: %s\r\n",
wnetcomData.txrxTaskState, wnetcomMsgFromClient);
if (strncmp((char*) wnetcomMsgFromClient, (const char *) "toggle D", 8) == 0)
{
if (wnetcomMsgFromClient[8] == '3')
{
BSP_LEDToggle(BSP_LED_3);
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: LED D%c is toggled\r\n",
wnetcomData.txrxTaskState, wnetcomMsgFromClient[8]);
}
if (wnetcomMsgFromClient[8] == '4')
{
BSP_LEDToggle(BSP_LED_4);
SYS_CONSOLE_PRINT("TCP_TXRX[%d]: LED D%c is toggled\r\n",
wnetcomData.txrxTaskState, wnetcomMsgFromClient[8]);
}
}
}
}
break;
All the necessary changes are complete. Feel free to modify the parsing code, add more states to the TXRX function to handle the closing of sockets, or implement timeout for sockets and so on.
- Save changes
- Click on Clean and Build Main Project icon in the MPLAB IDE toolbar
- Check for errors
V. PC interface to interact with the PIC32 based TCP server
Connect power supply and programmer tool to the Explorer 16 board.
Open Tera Term and select the serial interface instance created by Explorer 16 board. You may see a different COM# number. It will open a blank terminal window.
Click Make and Program Device Main Project icon in the MPLAB X IDE toolbar.
Once the PIC32 is successfully programmed, you will see the following messages on the serial terminal. These messages include system debug messages as well as console print statements that you just put in. Numbers in square brackets are the state numbers from respective functions for easier debugging.
Open a new Tera Term instance and select TCP/IP connections. Enter the WINC1500 IP address displayed in the console serial terminal and port number as set in MHC. Protocol as IPv4. (Configure it to echo typed chars)
In the newly opened TCP connection, you will receive the greeting from TCP server on PIC32. Enter LED toggle commands as toggle D3 and notice the output on the Explorer 16 board and the serial terminal.
Close the TCP client terminal and notice the output in the console. You can open a new TCP connection and test more.
VI. Adding Ethernet using MHC
Now that you have a working Wi-Fi project you can extend its functionality by adding Ethernet so that you can have simultaneous Wi-Fi and Ethernet.
You will be connecting the Fast 100 Mbps Ethernet PICtail™ Plus Daughter Board (ENC624J600) to the Explorer 16 Development Board or Explorer 16/32 Development Board with a PICtail Plus Expansion Board and communicating via the SPI2 serial interface. You will need to configure the following modules:
- TCP/IP Stack
- ENCx24J600 driver
- SPI driver
- Interrupt driver
Configuring the TCP/IP Stack:
In this step you will be configuring the TCP/IP stack to communicate with the Ethernet driver.
Expand the 'TCPIP stack' tree:
The TCP/IP Stack is already configured for one network interface: WINC1500.
- Change the 'Number of Network Configurations' to 2
- Under 'Network Configuration 1' tree:
- Set 'Interface' as ENCx24J600
- Enter an appropriate 'Host Name' (Example: PIC32_ENC)
Configuring the ENCx24J600 driver
In this step, you will be configuring the ENCx24J600 driver.
Under Drivers > ENCx24J600:
- Enable 'Use ENCx24J600 Driver?' by checking the box
Expand 'ENCx24J600 Driver Instance 0':
- Set 'SPI Driver Instance Number' to 1
This is because the SPI driver instance 0 is communicating with the WINC1500 Wi-Fi module.
- Set 'ENCx24J600 SPI Slave Select Port Pin' to PORTS_BIT_POS_12
To identify pin mappings for ENCx24J600 module refer to Appendix A-2.
ENC624J600 pin | PIC32 Pin Port | PIC32 Pin Bit |
---|---|---|
Interrupt | A | 15 (INT4) |
SPI Clock | G | 6 (SCK2) |
SPI Data IN | G | 8 (SDO2) |
SPI Data OUT | G | 7 (SDI2) |
SPI Slave Select | F | 12 |
Shutdown | F | 13 |
In the Pin Settings window
- Change the Direction (TRIS) and Latch (LAT) of RF12 (pin 40) and RF13 (pin 39) to Out and High.
Configuring the SPI Driver
In this step, you will be configuring the SPI driver to communicate with the ENC624J600 PICtail Plus daughter board via the SPI2 serial communications port.
Expand the 'SPI Driver' tree:
- Change the 'Number of SPI Driver Instances' to 2
Under 'SPI Driver Instance 1' tree:
- Under 'RTOS Configuration (Instance 1)', set 'Run This Driver Instance As' to Combined with System Tasks
- Set 'SPI Module ID' to SPI_ID_2
- Set 'Clock\Baud Rate - Hz' to 13333333
- Set 'Clock Mode' to DRV_SPI_CLOCK_MODE_IDLE_LOW_EDGE_FALL
- Set 'Input Phase' to SPI_INPUT_SAMPLING_AT_END
In the Pin Table, assign SPI2 (SPI_ID_2) pins as:
- SCK2 = pin 10 (RG6)
- SDI2 = pin 11 (RG7)
- SDO2 = pin 12 (RG8)
Setting External Interrupt System Service
In this step, you will be configuring the External Interrupt to communicate with the ENC62J600 PICtail Plus daughter board.
Under System Services > Interrupts:
- Change the 'Number of External Interrupt Instances' to 2
To be used by the ENC driver.
Under 'External Interrupt Instance 1':
- Change 'External Interrupt Module ID' to INT_EXTERNAL_INT_SOURCE_4
Because the ENCx24J600 interrupt pin connects to INT4.
- Enable 'Generate ISR Code?' by checking the box
- Set 'Interrupt Priority' to INT_PRIORITY_LEVEL3
- Set 'Interrupt Sub-priority' to INT_SUBPRIORITY_LEVEL1
- Set 'Polarity' to INT_EDGE_TRIGGER_FALLING
In the Pin Table, assign:
- pin 67 (RA15) to External Interrupt 4 Module
Completing the MHC Configuration
In the Generate Project window, select desired 'merging strategy' and click Generate.
In the merge window, ignore all the differences for wnetcom.c file and click Close. This happens because MHC is comparing a fresh TCP template with your modified one.
Modifying Application code
In order to use the Command System Service to receive commands from the serial terminal, you need to add SYS_CMD_READY_TO_READ() function to the application loop. The function is necessary for the Command System Service and Console System Service to function correctly. You will call it in WNETCOM_Tasks() function in WNETCOM_STATE_SERVICE_TASKS state.
SYS_CMD_READY_TO_READ();
VII. Testing Your New Application
Connect power supply and programmer tool to the Explorer 16. board.
Click Make and Program Device Main Project icon in the MPLAB X IDE toolbar.
Once the PIC32 is successfully programmed, you will see similar messages on the serial terminal as before (see Section V Step 5.
You can make use of TCP/IP Commands available in the Harmony TCP/IP Stack. In the serial terminal, type command netinfo and observe the output. It will show the details of available interfaces and their status. You may notice that the interface names will match with the ones entered in MHC TCP/IP Stack settings.
VIII. Instructions for migrating this project
Things to take care of when using different hardware:
Which peripheral can be used for console I/O? For example, on some boards, you might have to use the USB CDC console.
Expand the 'Console' tree:
- Set 'Select Peripheral For Console Instance' to USB_CDC_CONSOLE
Expand 'USB Library' tree:
Under 'USB Device Instance 0'
- Set 'Product ID Selection' to cdc_com_port_single_demo
The Product ID selection will populate the Vendor and Product IDs for the USB Device which are necessary for the USB device enumeration.
Figure out the connections for your hardware. For example, on the Curiosity PIC32MZEF Development Board, there is a MRF24WN0MA module populated. Figure out how it interfaces with the onboard PIC32 microcontroller. Change the Wi-Fi and SPI drivers accordingly. Please refer to the Curiosity demo available on its product page for more information.
Taking it further
- Try adding this Wi-Fi or Ethernet driver to an existing project to add connectivity.
- Study the demo “wifi_easy_configuration” located at C:\microchip\harmony\v2_04\apps\tcpip
- Study other interesting Harmony demo’s located in the install directory C:\microchip\harmony\v2_04\apps
- Visit Microchip Developer Help website (http://microchipdeveloper.com/harmony:start) for more tutorials.
IX. Troubleshooting
If you are having problems, please refer to the Microchip Support pages.
Appendix A
A-1 Pin mapping between PIC32MX plug-in-module (PIM) and WINC1500 PICtail module
This section demonstrates how to map a WINC1500 module pin to PIC32 microcontroller pin. Refer to the three figures below for Explorer 16 board, WINC1500 module and PIC32MX plug-in-module. An example of a pin mapping process is also provided after the third figure.
1. PICtail Plus connector on Explorer 16 board showing top socket:
2. WINC1500 PICTAIL/PICTAIL PLUS schematics:
3. Explorer 16 board schematic - PIM socket:
Using the three connection diagrams above, find the required plug-in-module(PIM) pins and then look-up those pins in the PIC32MX PIM sheet to get the actual microcontroller pins (As an example of mapping pins - WINC slave select connects to Pin 1 of J5 header on Explorer 16 board which connects to PIM pin 23 which is PIC32 device pin 69 > RD9.)
Here is a snapshot from the PIC32MX PIM sheet:
A-2 Pin mapping between PIC32MX plug-in-module and ENC624J600 PICTail module
1. ENC624J600 Fast 100 Mbps Ethernet PICtail Plus Daughter Board: