MPLAB Harmony v3 is now configurable through MPLAB Code Configurator (MCC). Although the instructions in this tutorial are for the MHC, the flow and experience of creating a project, configuring peripherals, and generating code using MCC are similar. Refer to the links below for specific instructions to use MPLAB Harmony v3 with MCC.
Objective
MPLAB Harmony v3 is a flexible, fully integrated embedded software development framework for 32-bit microcontrollers (MCUs) and microprocessors (MPUs).
MPLAB Harmony v3 includes the MPLAB Harmony Configurator (MHC) tool, a set of modular peripheral libraries, drivers, system services, middleware, and numerous example applications, all of which are designed to help you quickly and easily develop powerful and efficient embedded software for Microchip’s 32-bit PIC® and SAM devices.
This tutorial shows you how to use MHC to create a simple Webserver Application and will help you get started on developing Wi-Fi®-based applications for a PIC32 WFI32E MCU using the MPLAB Harmony v3 software framework.
Figure 1 is a screenshot of this training module application's output:
The training module application makes use of the PIC32 WFI32E Curiosity Board and the I/O1 Xplained Pro Extension Kit (sold separately).
This application reads the current room temperature from the AT30TSE758A temperature sensor chip on the I/O1 Xplained Pro every second using I²C. Further, it also writes and logs these temperature values into an SD card using a File System. The final application uses an RTOS to serve and run the applications as separate RTOS threads. The output is made available through the PIC32 WFI32E Curiosity Board's USB Power port by configuring it as a USB CDC class device. Through a Wi-Fi connection, the application exposes an HTTP web server to interact with the board and visualize the data over a graph.
The application you create will utilize the following Harmony v3 components:
- I²C Driver (I2C1) to fetch the temperature on the AT30TSE758A.
- Timer System Service (Core Timer) to periodically sample temperature sensor data every second.
- Debug System Service and Console System Service using CDC Function Driver of the USB Device Stack (FS USB) for printing the temperature over a serial terminal.
- Asynchronous SDSPI Driver (SPI2) to write temperature log to an SD card.
- File System Service interfaced with SDSPI Driver to perform file operations on the SD card.
- RTC Peripheral Library (RTCC) to capture temperature log time.
- FreeRTOS
- Wi-Fi System Service and Wi-Fi Provisioning Service which include PIC32MZW1 Drivers, TCP/IP Stack, Netconfig, Crypto Library, BA414E, wolfSSL Library, and the requested dependencies
- HTTP NET module (from the TCP/IP Stack) to parse the web page directly and process the commands through custom_http_net_app.c
The name of the peripheral used by a driver or library (as per the device datasheet) is mentioned in brackets for reference.
Two Ways to Use This Tutorial
- Create the project from scratch:
- Use the provided source files and follow the step-by-step instructions provided below.
- Use the attached project as an example:
- Build the attached project and program the PIC32 WFI32E Curiosity Board to observe the output.
Lab Objectives
- Create an MPLAB X IDE Harmony v3 project for a PIC32 WFI32E microcontroller from scratch.
- Use MHC to configure and generate code for the Harmony TIME System Service.
- Use MHC to configure and generate code for the Harmony I²C Driver and USB Device Stack Middleware (CDC Function Driver).
- Use MHC to configure and generate Harmony Peripheral Libraries for SPI and RTC.
- Use the Harmony Driver, System Service, Middleware, and Peripheral Library APIs to implement the application.
Materials
Hardware Tools
Tool | About | Purchase |
---|---|---|
PIC32 WFI32E Curiosity Board
Evaluation Kit |
| |
I/O1 Xplained Pro
Extension Kit |
| |
| | |
| |
For programming or debugging, the ICD4 connects to the host PC through the ICSP connector (J206) on the PIC32 WFI32E Curiosity Board.
Hardware Connection Setup
Apart from the hardware tools listed above, the following cables are required:
- One USB Type-A male to Micro-B male cable to power the board and exchange data over the USB CDC serial port.
- I/O1 Xplained Pro is connected to the PIC32 WFI32E Curiosity Board using the XPRO Header (J203).
- The serial terminal over the USB CDC interface is accessed via the TARGET USB Port.
- The external debugger/programmer is connected over the ICSP connector (J206).
Hardware Configuration
- Make sure the J202 jumper is connected to VBUS
- Make sure J301 jumpers are open (Pins 1-2 open, Pins 3-4 open)
Software Tools
This project has been verified to work with the following versions of software tools:
MPLAB X IDE v5.50 and MPLAB XC32 Compiler v3.01
Because we regularly update our tools, occasionally you may discover an issue while using the newer versions. If you suspect that to be the case, we recommend that you double-check and use the same versions that the project was tested with.
Tool | About | Installers |
Installation
Instructions |
||
---|---|---|---|---|---|
Windows | Linux | Mac OSX | |||
MPLAB® X
Integrated Development Environment |
| | | | |
MPLAB® XC32
C/C++ Compiler |
| | | | |
Package Name | Version Used | Description |
---|---|---|
bsp | v3.9.0 | Board Support Package: Includes templates and configuration data for supported development boards. |
CMSIS-FreeRTOS | v10.3.1 | FreeRTOS. |
core | v3.9.2 | Includes Drivers and Services with simple to use abstractions of peripherals and shared resources. |
crypto | v3.7.3 | Includes Cryptographic Module Library. |
csp | v3.9.1 | Chip Support Package: Includes the Peripheral Libraries (PLIBs). |
dev_packs | v3.9.0 | Describes all peripherals, memory, etc. of supported 32-bit devices. |
mhc | v3.8.0 | Contains the current implementation of the MHC tool. |
net | v3.7.2 | Network Library: Includes Drivers, Network presentation layer and TCP/IP stack. |
usb | v3.8.0 | Includes USB Middleware and Drivers. |
wireless_wifi | v3.5.1 | Wi-Fi Library: Includes the Drivers. |
wireless_system_pic32mzw1_wfi32e01 | v3.5.1 | Wireless System Services for PIC32MZW1 and WFI32E01. |
wolfssl | v4.7.0 | TLS/SSL Library implementation. |
Overview
This lab shows you how to create an MPLAB X Harmony v3 project from scratch and configure/generate code for the following:
- Harmony v3 Peripheral Libraries for RTCC, I²C, and SPI.
- Harmony v3 Driver for I²C.
- Harmony v3 SD Card Driver for SPI.
- Harmony v3 USB Full-Speed Driver and USB Device Stack Middleware (CDC Function Driver).
- Harmony v3 TIME System Service.
- Harmony v3 File System Service.
- Harmony v3 Core Service and FreeRTOS.
- Harmony v3 TCP IP Stack.
- Harmony v3 PIC32MZW1 Driver.
- Harmony v3 Wi-Fi System Services.
Lab Source Files and Solutions
This ZIP archive contains the completed project for this lab. It also contains the source files needed to perform the lab step-by-step as per the section "Procedure" on this page.
You are free to extract the contents of the archive to any directory of your choice. See the notes below.
Note:
- The project location of a Harmony v3 project is independent of the location of the Harmony Framework path (i.e., you do not need to create or place a Harmony v3 project in a relative path under the Harmony v3 framework folder). The project can be created or placed in any directory of your choice. As a good practice, reduce as much as possible the path length.
- The MHC generates all of the required source files, header files, and libraries (if any) under your project folder.
- This is unlike older Harmony v2 projects that are required to be created in a location under the Harmony framework.
Extracting the ZIP archive creates the following folders:
- getting_started_pic32_wfi32e contains the lab solution in the solution folder and source files in the dev_files folder.
- dev_files contains the application source files and other support files (if any) required to perform the lab.
- solution contains the completed lab solution project. You can directly build this project and program the hardware to observe the output.
Procedure
All steps must be completed before you will be ready to build, program, and run the application.
Lab Index
- Step 1 - Install the MHC Plug-in in MPLAB X IDE
- Step 2 - Create MPLAB Harmony v3 Project using MPLAB X IDE
- Step 3 - With MHC, verify System Clock Settings
- Step 4 - With MHC, configure I2C Driver, PLIB, Pins and Harmony Core
- Step 5 - With MHC, configure GPIO pin and interrupts
- Step 6 - With MHC, configure Debug System Service, Console System Service, USB Driver as CDC USB, and USB pins
- Step 7 - With MHC, configure System Time Service and Core Timer
- Step 8 - With MHC, view final project graph
- Step 9 - With MHC, generate code
- Step 10 - Add application code
- Step 11 - Build and Run the Application
- Step 1 - Rename Project
- Step 2 - With MHC, configure File System Service
- Step 3 - With MHC, configure SDSPI Driver, SPI Peripheral Library, and SPI pins
- Step 4 - With MHC, configure RTC Peripheral Library
- Step 5 - With MHC, configure Harmony Core and BSP
- Step 6 - With MHC, view final project graph and generate code
- Step 7 - Add code to the SDCARD application
- Step 8 - Build an Run the Application
Lab 3: Move Application into an RTOS
- Step 1 - Rename Project
- Step 2 - With MHC, configure FreeRTOS
- Step 3 - With MHC, verify I2C Driver, SDSPI Driver, File System Service configurations
- Step 4 - With MHC, configure Harmony Core
- Step 5 - With MHC, generate code
- Step 6 - Modify the I2C temperature sensor application and the SDCARD application
- Step 7 - Add code to USB debug application task
- Step 8 - Build and Run the Application
Lab 4: Add HTTP Web Server to Visualize Data
- Step 1 - Rename Project
- Step 2 - With MHC, configure TCPIP stack
- Step 3 - With MHC, configure HTTPNET server component
- Step 4 - With MHC, modify the configuration of the File System
- Step 5 - With MHC, configure Harmony Core
- Step 6 - With MHC, configure WIFI Service
- Step 7 - With MHC, generate code
- Step 8 - Add code to WIFI application task
- Step 9 - Build and Run the application