Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microchiptech/same51_ble_can_sniffer
"IoT Made Easy!" - RNBD451 BLE Peripheral Example: CAN Bus Sniffer
https://github.com/microchiptech/same51_ble_can_sniffer
ble can rnbd451 same51 sniffer
Last synced: about 13 hours ago
JSON representation
"IoT Made Easy!" - RNBD451 BLE Peripheral Example: CAN Bus Sniffer
- Host: GitHub
- URL: https://github.com/microchiptech/same51_ble_can_sniffer
- Owner: MicrochipTech
- Created: 2024-08-10T23:31:44.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-21T00:04:32.000Z (5 months ago)
- Last Synced: 2024-11-11T21:11:53.687Z (2 months ago)
- Topics: ble, can, rnbd451, same51, sniffer
- Language: C
- Homepage:
- Size: 30.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
- [Introduction](#introduction)
- [Hardware Requirements](#hardware-requirements)
- [Demo Platform Assembly](#demo-platform-assembly)
- [Software Requirements](#software-requirements)
- [Program Demo Firmware](#program-demo-firmware)
- [Testing Procedure](#testing-procedure)
- [Custom GATT Services](#custom-gatt-services)## Hardware Requirements
* Base Adapter Board: ["Curiosity Nano Base for Click Boards"](https://www.microchip.com/en-us/development-tool/ac164162)
* Host MCU Add-On Board: ["SAM E51 Curiosity Nano Evaluation Kit"](https://www.microchip.com/en-us/development-tool/ev76s68a)
* BLE Module: ["RNBD451 Add-on Board"](https://www.microchip.com/en-us/development-tool/ev25f14a) board featuring Microchip's [RNBD451PE](https://www.microchip.com/en-us/product/RNBD451PE) certified BLE module
* High Speed CAN FD Transceiver: ["ATA6563 Click"](https://www.mikroe.com/ata6563-click) featuring Microchip's [ATA6563](https://www.microchip.com/en-us/product/ata6563)
* USB-to-CAN Adapter for Host PC: ["PCAN-USB FD Adapter"](https://phytools.com/collections/peak-system-technik/products/pcan-usb-fd-adapter) manufactured by [phytools](https://phytools.com) (or equivalent diagnostic tool that can generate CAN messages)
## 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](https://www.microchip.com/mplab/mplab-x-ide) (when prompted, enable the installation of the [MPLAB IPE](https://www.microchip.com/en-us/tools-resources/production/mplab-integrated-programming-environment) 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](https://www.microchip.com/en-us/tools-resources/archives/mplab-ecosystem) (to fall back to the version Microchip successfully tested prior to release).- [MPLAB XC32 Compiler](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers#tabs)
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](https://www.microchip.com/en-us/tools-resources/archives/mplab-ecosystem) (to fall back to the version Microchip successfully tested prior to release).
- [MPLAB Harmony Software Framework](https://microchipdeveloper.com/harmony3:mhc-overview)
2. [Git](https://git-scm.com) (a free and open source distributed version control system)
- Download/install the latest version of [Git for Windows, macOS, or Linux](https://git-scm.com/downloads)
- Verify working operation of the `Git Bash` prompt (e.g. for Windows: click `Start` > type `Git Bash`)
3. Any [Terminal Emulator](https://en.wikipedia.org/wiki/List_of_terminal_emulators) program of your choice
4. [Microchip Bluetooth Data](https://play.google.com/store/apps/details?id=com.microchip.bluetooth.data&hl=en_US&pli=1) smartphone app
5. PCAN-USB FD Adapter [Device Driver for Windows](https://www.peak-system.com/quick/DrvSetup)
## Program Demo Firmware
1. Clone/download the MPLAB X demo project by issuing the following command line in a `Command Prompt` or `PowerShell` window.
```bash
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` button4. 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:
- Follow the procedure outlined in [Section 7.2.2.1](https://onlinedocs.microchip.com/oxy/GUID-26457D23-798C-47B0-9F40-C5DA6E995C6F-en-US-2/GUID-4D5EDD33-45BA-469D-BB9F-DE40465F8E82.html) ("Text Mode") of the [RNBD451 Bluetooth Low Energy User's Guide](https://onlinedocs.microchip.com/oxy/GUID-26457D23-798C-47B0-9F40-C5DA6E995C6F-en-US-2/index.html)
## 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 app5. 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](https://www.microchip.com/en-us/product/rnbd451pe) 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](https://www.microchip.com/en-us/product/rnbd451pe) BLE module, follow the procedure outlined in [Section 7.3](https://onlinedocs.microchip.com/oxy/GUID-26457D23-798C-47B0-9F40-C5DA6E995C6F-en-US-2/GUID-983D3FDA-5470-49F5-B8AC-E142DB5C1461.html
) (“Creating and Accessing GATT Services using UART Commands”) of the [RNBD451 Bluetooth Low Energy User's Guide](https://onlinedocs.microchip.com/oxy/GUID-26457D23-798C-47B0-9F40-C5DA6E995C6F-en-US-2/index.html)