"IoT Made Easy!"
Devices: | PIC32CXBZ2 | WBZ45x |
Features: | CAN | BLE |
THE SOFTWARE ARE PROVIDED "AS IS" AND GIVE A PATH FOR SELF-SUPPORT AND SELF-MAINTENANCE. This repository contains example code intended to help accelerate client product development.
For additional Microchip repos, see: https://github.com/Microchip-MPLAB-Harmony
Checkout the Technical support portal to access our knowledge base, community forums or submit support ticket requests.
This document describes how to program a Microchip WBZ45x BLE SoC certified RF module to connect to a smartphone while monitoring messages received over its connected CAN bus. A sample smartphone app is provided to communicate with the SoC via BLE and display the CAN messages received by the BLE SoC. A Host PC running a terminal emulator serves as a debug window to display diagnostic messages sent by the BLE SoC module.
- Introduction
- Hardware Requirements
- Demo Platform Assembly
- Software Requirements
- Program Demo Firmware
- Connect to Smartphone App
- Testing Procedure
- Transparent UART Service
-
BLE SoC Certified RF Module: "WBZ451 Curiosity Development Board"
-
High Speed CAN FD Controller + Transceiver: "MCP251863 Click" featuring Microchip's MCP251863
-
USB-to-CAN Adapter for Host PC: "PCAN-USB FD Adapter" manufactured by phytools (or equivalent diagnostic tool that can generate CAN messages)
-
Choose one of the following methods to connect the MCP251863 Click board to the WBZ451 Curiosity development board:
-
Connect the Host PC to the WBZ451 Curiosity development board using a micro-USB cable and note the new Virtual COM port number that is associated with your connection (e.g. use the Windows Device Manager and look for
USB Serial Device
). -
Using a DB-9 female-to-female serial cable, connect the PCAN-USB FD Adapter to the MCP251863 Click board, then connect the adapter's USB cable to an available USB port of the Host PC.
Embedded software development tools need to be installed in order to properly program (and interact with) the WBZ451 Curiosity Development Board.
-
Microchip
MPLAB X
tool chain for embedded code development on 32-bit architecture MCU/MPU platforms (made up of 3 major components)-
MPLAB X IDE (when prompted, enable the installation of the MPLAB IPE too)
NOTE: This demonstration project was last tested successfully with MPLAB X v6.20. If a previous version of the IDE is needed, download it from the MPLAB Development Ecosystem Downloads Archive (to fall back to the version Microchip successfully tested prior to release).
-
NOTE: This demonstration project was tested successfully with XC32 v4.45, and in general should work with later versions of the compiler as they become available. If you encounter issues building the project with a newer version of the compiler, it is recommended to download the compiler version that was last tested successfully from the MPLAB Development Ecosystem Downloads Archive (to fall back to the version Microchip successfully tested prior to release).
-
MPLAB Harmony Software Framework
- csp version: v3.14.0
- core version: v3.11.1
- CMSIS-FreeRTOS: v10.4.6
- wireless_pic32cxbz_wbz: v1.1.0
- dev_packs: v3.14.0
- wolfssl version: v4.7.0
- crypto version: v3.7.6
- wireless_ble: v1.0.0
-
-
Git (a free and open source distributed version control system)
-
Download/install the latest version of Git for Windows, macOS, or Linux
-
Verify working operation of the
Git Bash
prompt (e.g. for Windows: clickStart
> typeGit Bash
)
-
-
Any Terminal Emulator program of your choice
-
Microchip Bluetooth Data smartphone app
-
PCAN-USB FD Adapter Device Driver for Windows
-
Clone/download the MPLAB X demo project by issuing the following command line in a
Command Prompt
orPowerShell
window.git clone https://github.com/MicrochipTech/WBZ45x_BLE_CAN_Sniffer.git
-
Launch the MPLAB X IDE.
-
Open the demo project:
- From the MPLAB X mail toolbar, select
File > Open Project
- Navigate to the
WBZ45x_BLE_CAN_Sniffer\firmware
folder - Select (click on) the
bleCan_Peripheral.X
project folder - Click on the
Open Project
button
- From the MPLAB X mail toolbar, select
-
Clean and build the project:
-
Program the WBZ451 BLE SoC:
-
Open the Microchip MBD Application on Mobile phone and click on BLE Smart to scan for the available devices.
-
The MBD App will scan for the available devices and the scan result will be shown as below. Select "CAN BLE Bridge Device" from the scan list.
-
Click on the Connect button to establish a BLE Connection with the device.
-
Once BLE Connection is established and service discovery is completed, Transparent UART Service is discovered and shown as Microchip Data Service as shown below.
-
To view the CAN messages transmitted via BLE, select the Transparent UART TX Characteristic (UUID ending with 9616) as shown below.
-
In the Characteristics page, enable notify/indicate as shown below.
-
Open a serial terminal window (e.g. TeraTerm) and connect to the COM port corresponding to your board (e.g. choose
File
> chooseNew connection
> chooseSerial
> selectUSB Serial Device
). -
Set the baud rate for the COM port connection at
115200 baud
(e.g. chooseSetup
> chooseSerial port
> type in115200
for the speed > clickNew setting
). -
Press the RESET button on the WBZ451 Curiosity development board and confirm that the application firmware outputs a couple of opening messages to the serial terminal window.
-
Launch the
PCAN-View
PC application. -
In the
CAN Setup
tab, selectSAE J2284-4 (500k/2M)
for the Bit Rate Preset: -
Create/transmit a new standard CAN message by selecting
File > New Message
in the PCAN-View's main toolbar. In the New Transmit Message pop-up window:-
Enter an ID that's less than 0x800
-
Select the number of data bytes in the message and set the value of each byte as desired
-
Under Message Type, ensure that only the boxes checked are for
CAN FD
andBit Rate Switch
-
Enter a cycle time to send out the same message periodically (in milliseconds)
-
Click on the OK button to start the transmission of repeating messages
-
-
Confirm that the standard CAN message transmissions are received and displayed in the Microchip Bluetooth Data (MBD) smartphone app.
-
Create/transmit a new extended frame CAN message by selecting
File > New Message
in the PCAN-View's main toolbar. In the New Transmit Message pop-up window:-
Enter an ID that's greater than or equal to 0x10000
-
Select the number of data bytes in the message and set the value of each byte as desired
-
Under Message Type, ensure that the 3 boxes checked are
Extended Frame
,CAN FD
, andBit Rate Switch
-
Enter a cycle time to send out the same message periodically (in milliseconds)
-
Click on the OK button to start the transmission of repeating messages
-
-
Confirm that the extended frame CAN message transmissions are received and displayed in the Microchip Bluetooth Data (MBD) smartphone app.
-
Discontinue the continuous sending of repeated CAN messages by unchecking the boxes under the
Cycle Time
column in thePCAN-View
application. TheCount
values for each message in theTransmit
window should all stop incrementing. -
In the MBD mobile app, back out of the current screen and hit
DISCONNECT
in the top right corner. Back out of the current screen 2 more times to return to the main menu of the Microchip Bluetooth Data app. -
Starting at the main menu of the MBD app, select
BLE UART
>PIC32CXBZ
>SCAN
.CAN BLE Bridge
should show up in the list of devices; hitCANCEL
to stop scanning then selectCAN BLE Bridge
. -
At the bottom of the screen, select
Text mode
. In theEnter text here
box, try sending a BLE data message to the WBZ451 Curiosity development board to turn on its RGB LED by sending one or more of the following command strings (case sensitive):+LED_BLUE:ON +LED_GREEN:ON +LED_RED:ON
-
Each input into the RGB LED can also be turned off by sending any of the following command strings (case sensitive):
+LED_BLUE:OFF +LED_GREEN:OFF +LED_RED:OFF
-
Issue the command to get the status of the 3 inputs to the RGB LED by sending the following command string (case sensitive):
+STATUS:
-
Confirm that a response was received from the WBZ451 regarding the states of the 3 inputs to the RGB LED. A capital letter means the input is on and lower case letter means the input is off. For example, if only the blue input is on, the format of the response should be
+RGB: r g B
-
Send any ASCII text string and confirm that the message is displayed in the terminal window.
-
Initiate the transmission of an example CAN message to the CAN bus (via the CAN controller) by sending the following command string (case sensitive):
+CAN:TX
-
Confirm that the sample CAN message is displayed in the PCAN-View
Receive
tab as well as the terminal window.
This demo application uses Microchip's Transparent UART Service (TRSPS) to transfer data bi-directionally between the BLE Central & Peripheral devices.
As a GATT Server, the WBZ451 module hosts the Microchip Transparent UART Service. The Transparent UART Service provides a simple bidirectional data transfer service. It defines two Generic Attribute Profile (GATT) characteristics for the serial-like data communication:
- Receiving data with the Write property
- Sending data with the Notify property