Skip to content

"IoT Made Easy!" - RNBD451 BLE Peripheral Example: CAN Bus Sniffer

Notifications You must be signed in to change notification settings

MicrochipTech/SAME51_BLE_CAN_Sniffer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ATSAME51 BLE Peripheral Example : CAN Bus Sniffer

"IoT Made Easy!"

Devices: | ATSAME51 | RNBD451 |
Features: | CAN | BLE |

⚠ Disclaimer

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.

Introduction

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.

Table of Contents

Hardware Requirements

Demo Platform Assembly

  1. Set the jumper on the RNBD451 Add-On Board so that the two pins furthest away from the module are shorted.

  2. Install the RNBD451 Add-On Board onto mikroBUS socket #2 of the Curiosity Nano Base.

  3. 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.

  4. 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).

  5. Install the ATA6563 Click board onto mikroBUS socket #1 of the Curiosity Nano Base.

  6. 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.

  7. Confirm that all boards and connections have been made for the complete hardware platform.

Software Requirements

Embedded software development tools need to be installed in order to properly program (and interact with) the WBZ451 Curiosity Development Board.

  1. 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).

    • MPLAB XC32 Compiler

      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

  2. 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: click Start > type Git Bash)

  3. Any Terminal Emulator program of your choice

  4. Microchip Bluetooth Data smartphone app

  5. PCAN-USB FD Adapter Device Driver for Windows

Program Demo Firmware

  1. Clone/download the MPLAB X demo project by issuing the following command line in a Command Prompt or PowerShell window.

    git clone https://github.com/MicrochipTech/SAME51_BLE_CAN_Sniffer.git
  2. Launch the MPLAB X IDE.

  3. 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
  4. Clean and build the project:

    • Click on the Clean and Build Main Project icon in the MPLAB X main toolbar

  5. Program the ATSAME51 Host MCU:

    • Click on the Make and Program Device Main Project icon in the MPLAB X main toolbar

    • Verify that the programming phase was successful

  6. Connect a smartphone to the RNBD451 BLE module using the Microchip Bluetooth Data (MBD) app:

Testing Procedure

  1. Open a serial terminal window (e.g. TeraTerm) and connect to the COM port corresponding to your board (e.g. choose File > choose New connection> choose Serial> select USB Serial Device).

  2. Set the baud rate for the COM port connection at 115200 baud (e.g. choose Setup > choose Serial port> type in 115200 for the speed > click New setting).

  3. 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.

  4. 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
  5. Send text messages from the Host PC to the smartphone:

    • Type characters in the terminal window and confirm reception/display in the MBD app
    • Type characters in the MBD app and confirm reception/display in the terminal window
  6. Launch the PCAN-View PC application.

  7. In the CAN Setup tab, select SAE J2284-4 (500k/2M) for the Bit Rate Preset:

  8. In the serial terminal window, type M or m to bring up the list of available CAN operations. Enter the keys 1, 2, 3, 4, & 5 to send out sample standard and extended CAN messages.

  9. In the PCAN-View GUI, confirm that 5 different CAN messages show up in the Receive window.

  10. 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 and Bit 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

  11. 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, and Bit 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

  12. 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.

  13. Confirm that the same periodic CAN message transmissions are displayed in the Microchip Bluetooth Data (MBD) smartphone app.

Custom GATT Services

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

About

"IoT Made Easy!" - RNBD451 BLE Peripheral Example: CAN Bus Sniffer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published