Rapid prototyping with 32-bit MCU-based Curiosity Nano Evaluation Kit using MPLAB® Harmony v3 Software Framework
Objective
This tutorial shows you how to develop an application prototype from a concept without designing a Printed Circuit Board (PCB) using 32-bit MCU-based Curiosity Nano Evaluation Kits and Nano baseboard.
The problem statement you would address is implementing a smart appliance control application on the PIC32CM MC00 Curiosity Nano Evaluation Kit using MPLAB® Harmony v3 software framework.
The application makes use of the PIC32CM MC00 Curiosity Nano Evaluation Kit, the BM71-XPRO Bluetooth® Low energy board, and the following MikroElektronika Click boards™: Weather CLICK, Fan Click, eINK Click Bundle.
The application is developed on the MPLAB Harmony v3 software framework. MPLAB Harmony v3 is a modular framework that provides interoperable firmware libraries for application development on 32-bit MCUs and MPUs. It includes an easy-to-use Graphical User Interface (GUI) (MPLAB Harmony Configurator (MHC)) for selecting, configuring, and generating starter codes, peripheral libraries, and middleware (USB, TCP/IP, Graphics, and so on).
This application demonstrates smart control of an appliance (fan) through an Android-based smartphone over a Bluetooth Low Energy (BLE) connection.
The application enables BLE transfers by connecting the BM71 XPRO to the Microchip Bluetooth Data (MBD) Android smartphone application. The BM71 XPRO uses a transparent service for data exchange with the Android MBD mobile application. The BM71 XPRO interfaces to the MCU over SERCOM - USART interface.
The fan connected to Fan Click via the Inter-Integrated Circuit (I²C) interface is controlled based on the mobile application's commands. The application supports two types of commands received over BLE.
- Environment temperature-based Fan Control mode command
- When the application receives a command TEMP_CTRL from the Android smartphone, the fan is run based on the environmental temperature. The application reads the temperature values from a weather sensor and displays them on the eINK display and controls a DC fan as mentioned below.
- The fan rotates at LOW speed at a temperature between 18 (64°F) to 25 (77°F) degrees Celsius
- The fan rotates at MEDIUM speed at a temperature between 26 (78°F) to 30 (86°F) degrees Celsius
- Temperature is greater than 30 degrees Celsius (86°F), the fan rotates at HIGH speed
- Temperature is less than 18 (64°F), the fan is switched OFF
- When the application receives a command TEMP_CTRL from the Android smartphone, the fan is run based on the environmental temperature. The application reads the temperature values from a weather sensor and displays them on the eINK display and controls a DC fan as mentioned below.
- Fan operation control based on the commands received from the Android smartphone.
- You can control the fan by sending specific commands to the MBD app running on the connected smartphone
- BLE_CTRL: FAN_ON - Turns the fan "On" and runs at LOW speed
- BLE_CTRL: FAN_OFF - Turns "Off" the fan
- BLE_CTRL: FAN_LOW - Runs the fan at LOW speed
- BLE_CTRL: FAN_MID - Runs the fan at MEDIUM speed
- BLE_CTRL: FAN_HIGH - Runs the fan at HIGH speed
- You can control the fan by sending specific commands to the MBD app running on the connected smartphone
The application you create will utilize the following peripherals:
- SERCOM0 (as I²C) peripheral library to read the temperature from the Weather Click sensor and control the speed of the 5 V DC fan using the Fan Click
- SERCOM1 (as SPI) peripheral library to display the temperature and fan speed status on the eINK display
- SERCOM3 (as Universal Synchronous Asynchronous Receiver Transmitter (USART)) peripheral library to communicate with the BM71-XPRO using the BM71 Driver
- SysTick and Timer (TC0) peripheral libraries are used for MikroElektronika board and BM71 driver timing requirements
There are Two Approaches to This Tutorial
Create the project from scratch:
- Use the provided source files and step-by-step instructions below
- Use the solution project as an example:
- Build the solution project and download it to the PIC32CM MC00 Curiosity Nano Evaluation Kit to observe the expected behavior
Lab Objectives
Create an MPLAB X IDE Harmony v3 project for a PIC32CM MC00 MCU from scratch.
- Use MHC to configure and generate Harmony v3 Peripheral Library code for SysTick, I²C, USART, SPI, TC0, and PORT peripherals.
- Use MHC to configure and generate Harmony v3 BM71 driver, and Timer System Service libraries.
- Use MikroElektronika Click routines to add MikroElektronika Click board functionality to the application.
- Use the Harmony v3 Peripheral Library Application Programming Interfaces (APIs) to implement and demonstrate a low-power application.
Materials
Hardware Tools
- PIC32CM MC00 Curiosity NANO Evaluation Kit
- Curiosity NANO Base For Click Boards™
- BM71-XPRO Bluetooth Low Energy Daughter board
- Weather Click board
- Fan Click board
- eINK Click Bundle
- 5V DC Fan
- 3.7V 5000mAH Lipo Rechargeable Battery
Software Tools
This project has been verified to work with the following versions of software tools:
- MPLAB X IDE v5.50
- MPLAB XC32 Compiler v3.00
- MPLAB Harmony CSP v3.9.1
- Core v3.9.1
- DEV_PACKS v3.9.0
- MHC v3.7.2
- bt v3.4.1
- Microchip Bluetooth Data Android App
For this lab, download the following repositories from GitHub:
- CSP: The following table shows the summary of contents
Folder | Description |
---|---|
apps | Example applications for CSP library components |
arch | Initialization and starter code templates and data |
docs | CSP library help documentation |
peripheral | Peripheral library templates and configuration data |
- DEV_PACKS: The following table shows the summary of contents
Folder | Description |
---|---|
Microchip | Peripheral register specific definitions |
arm | Core Specific Register Definitions (CMSIS) |
- MHC: The following table shows the summary of contents
File/Folder | Description |
---|---|
doc | Help documentation and licenses for libraries used |
np_templates | New Project templates for supported toolchains |
*.jar | Java implementations of MHC modules |
mhc.jar | Main Java executable (run: java -jar mhc.jar -h) |
runmhc.bat | Windows cmd batch file to run standalone MHC Graphical User Interface (GUI) |
- bt: The following table shows the summary of contents
Folder | Description |
---|---|
apps | Example applications for Bluetooth library components |
docs | Bluetooth module library help documentation |
driver | Bluetooth module peripheral device drivers |
templates | Application and system file templates |
- Use the MPLAB Harmony 3 Content Manager (MHCM) to download the repositories
Overview
This lab shows you how to create an MPLAB Harmony v3 project from scratch. You will configure and generate Harmony v3 peripheral library code for the SysTick, I²C, USART, SPI, BM71 driver, Timer System Services, TC0, and PORT peripherals.
The application flow is as follows:
- The application initializes the Fan Click board routines, eINK Click board routines, and sets the default state of the fan to OFF.
- The application initializes the BLE and runs the BLE Tasks.
- The application checks whether the fan control command from the BLE-based Android smartphone app is:
- Temperature-based control or
- BLE-based control
- If the command is temperature-based control, the application flow is as below:
- Through the I²C interface, reads the room temperature from the PTH sensor on the Weather Click
- Checks the room temperature reading against the requirement and, through the I²C interface, controls the state and speed of the fan connected to the Fan Click board and displays the temperature and fan speed on the eINK display
- If the command is BLE-based control, the application sets the fan operation (SPEED, ON/OFF) based on the command received and displays the fan speed on eINK display.
- The process is repeated to monitor the room temperature and control the fan operation continuously.
Lab Source Files and Solutions
This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab by following the step-by-step instructions (see the "Procedure" section on this page).
ZIP
Extracting the ZIP file creates the following folders:
- pic32cmmc_smart_appliance_control contains the lab solution (in the firmware folder) and source files (in the dev_files folder)
- dev_files contains subfolder pic32cm_mc00_cnano which contains application source files and other support files (if any) required to perform the lab (see "Procedure" section below)
- firmware contains the completed lab solution project. It can be directly built and downloaded on the hardware to observe expected behavior
Hardware Configuration and Connections
The BM71 XPRO needs to be upgraded with firmware having private characteristics and configured to run in Manual mode. The steps to do the same are mentioned below.
Adding private characteristics to BM71:
Hardware Setup
In BM71-XPRO, change jumper J2 to select USB
- In BM71-XPRO, configure DIP switch SW2 with the below configurations
- All DIP switch ON
- Power the BM71-XPRO from a Host PC through a Type-A male to Micro-B USB cable connected to Micro-B port (J1)
- Perform reset by pressing switch SW1 on the BM71-XPRO and check blue LD1 is ON
Programming private characteristics
- Download the manual configuration tool from BM70/71 Firmware & Software Tools v1.11
- Extract and locate configuration tool from the below location
- Your_downloaded_folder \Firmware & Software Tools v1.11\ConfigurationTool\IS187x_102_BLEDK3v1.11_UI1.00
- Double click on IS187x_102_BLEDK3v1.11_UI1.00.exe
- Click on Load button and select Load Text File
- Select IS1871SF_102_BLEDK3v1.11_UI v1.00(BM71)_default.txt from your_downloaded_folder\Firmware & Software Tools v1.11\ConfigurationTool\IS187x_102_BLEDK3v1.11_UI1.00
- Click on the EDIT option
- Select 0x01: BM71 in BLEDK and click OK
- Update the Operation Mode Setting from Auto Pattern to Manual Pattern
- Confirm OK to disable the "Flow Control and LE Connection Parameter Update Request"
- Click on Finish
- Click on Write
- Select the respective COM Port and set Baudrate to 115200 then click on Write
- Click on Yes to successfully update the private characteristics on to BM71 module
- After successful update, click OK and remove the power from BM71-XPRO and change jumper J2 to select EXT
- Turn OFF DIP 1 switch
Hardware Connection Setup
- Mount the PIC32CM MC00 Curiosity Nano Evaluation Kit on the CNANO56_HOST_CONN(U3) connector of the Curiosity Nano Baseboard
- Connect the BM71-XPRO onto the EXT 1 connector of the Curiosity Nano Baseboard
- Mount the eINK Click bundle (eINK Click + eINK display) on the mikroBUS 1 connector of the Curiosity Nano Baseboard
- Mount Fan Click board on the mikroBUS click 2 connector of the Curiosity Nano Base and connect 4 fan wires to the fan Click
- Mount the Weather Click board on the mikroBUS click 3 connector of Curiosity Nano Base
- Connect Li-ion or Lipo Battery on J1 connector and make sure SW1 slider switch is moved to the battery on the position in Curiosity Nano Baseboard
- Connect the PIC32CM MC00 Curiosity Nano Evaluation Kit to the Host PC as a USB Device through a Type-A male to micro-B USB cable connected to Micro-B USB (Debug USB) port
Procedure
Lab Index
Step 1: Create Project and Configure the PIC32CM MC00
- Step 1.1 - Verify Whether MHC Plug-in is Installed in MPLAB X IDE
- Step 1.2 - Set Up MHC Plugin Window to Open in Standalone Mode
- Step 1.3 - Create MPLAB Harmony v3 Project Using MPLAB X IDE
- Step 1.4 - Configure Clock Settings
Step 2: Configure I²C Peripheral Library
- Step 2.1 - Configure I²C Peripheral Library and I²C Pins
Step 3: Configure SPI and SysTick Peripheral Library
- Step 3.1 - Configure SPI Peripheral Library and SPI Pins
- Step 3.2 - Configure SysTick Peripheral Library
Step 4: Configure UART Peripheral Library and Asscoiate BM71 driver
- Step 4.1 - Configure UART Peripheral Library and UART pins
- Step 4.2 - Associate BM71 Driver
- Step 4.3 - Configure Timer and Harmony Core Services
Step 6: Add MikroElektronika routine Code to the Project
- Step 6.1 - Add Weather click board routine
- Step 6.2 - Add Fan click board routine
- Step 6.3 - Add EINK click board routine
- Step 6.4 - Add BLE source files
- Step 6.5 - Map generic Macros of click routines
Step 7: Add Application Code to the Project
Step 8: Build, Program, and Observe the Outputs