"IoT Made Easy!"
Devices: | ATSAME51 | RNBD451 |
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 32-bit Cortex-M4F MCU to connect to a Smartphone via BLE while monitoring messages received over its connected CAN bus. A sample smartphone app is provided to communicate with the MCU via BLE and display the CAN FD messages received by the MCU. A Host PC running a terminal emulator serves as a debug window to send/receive diagnostic messages to/from the Host MCU.
- Introduction
- Hardware Requirements
- Demo Platform Assembly
- Software Requirements
- Program Demo Firmware
- Testing Procedure
- Custom GATT Services
-
Base Adapter Board: "Curiosity Nano Base for Click Boards"
-
Host MCU Add-On Board: "SAM E51 Curiosity Nano Evaluation Kit"
-
BLE Module: "RNBD451 Add-on Board" board featuring Microchip's RNBD451PE certified BLE module
-
High Speed CAN FD Transceiver: "ATA6563 Click" featuring Microchip's ATA6563
-
USB-to-CAN Adapter for Host PC: "PCAN-USB FD Adapter" manufactured by phytools (or equivalent diagnostic tool that can generate CAN messages)
-
Set the jumper on the RNBD451 Add-On Board so that the two pins furthest away from the module are shorted.
-
Install the RNBD451 Add-On Board onto mikroBUS socket #2 of the Curiosity Nano Base.
-
Connect the supplied 28-pin headers underneath the SAM E51 Curiosity Nano (soldering is optional) and then install the SAM E51 Curiosity Nano onto the 56-pin socket of the Curiosity Nano Base.
-
Connect the PC to the SAM E51 Curiosity Nano 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
). -
Install the ATA6563 Click board onto mikroBUS socket #1 of the Curiosity Nano Base.
-
Using a DB-9 female-to-female serial cable, connect the PCAN-USB FD Adapter to the ATA6563 Click board, then connect the adapter's USB cable to an available USB port of the Host PC.
-
Confirm that all boards and connections have been made for the complete hardware platform.
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).
-
-
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/SAME51_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
SAME51_BLE_CAN_Sniffer\firmware
folder - Select (click on) the
sam_e51_cnano_rnbd451.X
project folder - Click on the
Open Project
button
- From the MPLAB X mail toolbar, select
-
Clean and build the project:
-
Program the ATSAME51 Host MCU:
-
Connect a smartphone to the RNBD451 BLE module using the Microchip Bluetooth Data (MBD) app:
- Follow the procedure outlined in Section 7.2.2.1 ("Text Mode") of the RNBD451 Bluetooth Low Energy User's Guide
-
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
). -
It is recommended to enable the "Local Echo" feature in the terminal settings in order to see every key that's typed into the terminal window.
-
Change the toggle rate of
LED0
on the SAM E51 Curiosity Nano board:- Press the SW0 button on the SAM E51 Curiosity Nano and note the LED toggle rate change on every press
- View the toggle rate confirmation messages in the Microchip Bluetooth Data (MBD) smartphone app
-
Send text messages from the Host PC to the smartphone:
-
Launch the PCAN-View PC application.
-
In the
CAN Setup
tab, selectSAE J2284-4 (500k/2M)
for the Bit Rate Preset: -
In the serial terminal window, type
M
orm
to bring up the list of available CAN operations. Enter the keys1
,2
,3
,4
, &5
to send out sample standard and extended CAN messages. -
In the PCAN-View GUI, confirm that 5 different CAN messages show up in the
Receive
window. -
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 0x7FF
-
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
-
-
Create/transmit a new extended 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
-
-
In the
Transmit
window of the PCAN-View GUI, confirm that both messages are being received periodically based on the settings of each message's cycle time. -
Confirm that the same periodic CAN message transmissions are displayed in the Microchip Bluetooth Data (MBD) smartphone app.
The RNBD451 BLE module allows the user to create Bluetooth SIG-defined public GATT services as well as customer private services through simple UART commands. The specifications published by the Bluetooth SIG defines the public GATT services while the user defines their own private GATT services.
For an example of creating/programming a custom GATT service into the RNBD451PE BLE module, follow the procedure outlined in Section 7.3 (“Creating and Accessing GATT Services using UART Commands”) of the RNBD451 Bluetooth Low Energy User's Guide