- Introduction
- Driver Information
- Related Documentation
- Software Used
- Hardware Used
- Hardware Setup
- Software Prerequisite
- Project Setup
- RNBD Setup and Running Example Application
- RNBD Basic Data Exchange Pin Settings
- RNBD Transparent UART Application Pin Settings
- RNBD GPIO Based Connection Setup
- RNBD Code Generation and Compilation
- RNBD Example 1: Running Basic Data Exchange Example Application
- RNBD Example 2: Running Transparent UART Example Application
- RN487x Setup and Running Example
- RN487x Basic Data Exchange Pin Settings
- RN487x Transparent UART Application Pin Settings
- RN487x Code Generation and Compilation
- RN487x Example 1: Running Basic Data Exchange Example Application
- RN487x Example 2: Running Transparent UART Example Application
- Summary
- **Notes**:
- The project creation steps where RNBD is mentioned are applicable for both RNBD451 and RNBD350 devices.
2. The Over-the-Air (OTA) Device Firmware Update (DFU) support is not applicable for RNBD350-based applications because the OTA DFU for RNBD350 is implemented using the Host Microcontroller (MCU) DFU process. OTA is not supported for 8-bit applications due to memory limitation.
The MPLAB® Code Configurator (MCC) RNBD/RN487x Bluetooth® Low Energy (BLE) Modules Library allows to promptly configure the C code-generated software driver, based on the user’s selected Application Programming Interfaces (API) features available in the MCC Library. The generated driver code can support the BLE module using a PIC® device.
Refer to the /images folder for source files and max resolution.
The library module uses an MCC Graphic User Interface (GUI) to set the configuration, along with the custom configurations of the protocol. The customized C code is generated in a folder named "MCC Generated Files" within the MPLAB X project.
This library uses one Universal Asynchronous Receiver and Transmitter (UART), one General Purpose Input/Output (GPIO) and DELAY support at minimal.
-
Microchip Bluetooth Low Energy (BLE)
-
RNBD User Guide (RNBD451)
-
RNBD Data Sheet (RNBD451 DS)
-
PIC18F47Q10 Product Page (PIC18F47Q10)
-
RN Data Sheet (RN4870/1)
-
RN User Guide (RN4870/1)
-
MPLAB® X IDE 6.20 or newer
-
MPLAB XC8 2.46 or newer
-
MPLAB Code Configurator 5.5.1 or newer
-
MPLAB Code Configurator Device Libraries PIC10 / PIC12 / PIC16 / PIC18 Microcontrollers (MCUs)
-
MPLAB Code Configurator Device Libraries PIC® MCUs
-
Microchip PIC18F-Q_DFP Series Device Support (1.25.433) or newer
-
Pin mapping table between the MCU and the RNBD Click:
S. No Pin Functionality PIC RNBD Click 1 Receive (RxD) RB3 Tx 2 Transmit (TxD) RB0 Rx 3 BT_RST RC7 RST -
Connect the development board of your choice and then connect the RNBD to the proper slot. The image below shows how to connect the RNBD Click to Slot 2.
Important: The slot was decided based on the UART instances which were configured for this example (see the pin mapping table between the MCU and the RNBD Click).
-
Pin mapping table between the MCU and the RN487x Click:
S. No Pin Functionality PIC RN487x Click 1 Receive (RxD) RB3 Tx 2 Transmit (TxD) RB0 Rx 3 BT_RST RC7 RST -
Connect the development board of your choice and then connect the RN487x to the proper slot. The image below shows how to connect the RN487x Click to Slot 2.
Important: The slot was decided based on the UART instances which were configured for this example application (see the pin mapping table between the MCU and the RN487x Click).
Install the MPLAB Code Configurator Plug-in:
- Go to the MPLAB Code Configurator page
- In MPLAB X IDE, select Plugins from the Tools menu.
- Select the Available Plugins tab.
- Check the box for the MPLAB Code Configurator v3 and click Install.
Note: The Validation Hardware used with Microchip Bluetooth Data Mobile App is shown in the process below. PIC18F47Q10 8-bit devices are used for reference.
-
Open MCC by clicking Tools→Embedded→MPLAB® Code Configurator or click the MCC button.
or
-
If MCC is not available, install it. Navigate to Tools→Plugins. Under Available Plugins select "MPLAB Code Configurator", ensure the checkbox is selected and press Install. Once the installation is completed, MCC will be available.
-
On launching MCC, click the Content Manager button.
WARNING Use the mentioned driver versions only as shown in the image below! -
Go to Device Resources→Libraries→rnbd-rn487x-host-driver→RNBD-RN487x.
- Once the RNBD-RN487x driver was loaded to the Project Resources panel, choose the EUSART1 Peripheral Library (PLIB) selection from UART driver, in which the GUI will be expanded for another configuration setting tab
-
The Notifications [MCC] tab will appear after the library addition to describe the required actions. The library requires the Reset Pin to be "connected to the module", which needs to be assigned to a pin. Select and configure the dependent UART instance under Dependency Selector.
-
Generate example applications:
-
Clock settings:
-
UART settings:
This section explains the RNBD MPLAB X IDE project setup, code generation, and shows how to run the Basic Data Exchange and Transparent UART applications with the PIC18F47Q10 microcontroller.
-
PIC18F47Q10 MCC Configuration - Basic Data Exchange Example
- Set "Device Selection" to RNBD
- Enable "Sample Examples"
- Expand "Reference Examples" and select Basic Data Exchange
Notes:
-
The Basic Data Exchange application uses only one instance of UART1 (PLIB ---> EUSART1) for data transfer.
-
Important: For EUSART Rx1 and Tx1, deselect the checkboxes in the Analog, Slew Rate and Input Level Control columns.
Configuration for PIC Basic Data Exchange was completed. Click here for the RNBD code generation and compilation section.
-
PIC18F47Q10 MCC Configuration - Transparent Serial Example
- Set "Device Selection" to RNBD
- Enable "Sample Examples"
- Expand "Reference Examples" and select Transparent UART application
Notes:
-
The Transparent UART application uses two instances of UART1 and UART2 (PLIB ---> EUSART1 and EUSART2) for data transfer.
-
Important: For EUSART Rx1 and Tx1, deselect the checkboxes in the Analog, Slew Rate and Input Level Control columns.
Configuration for PIC Transparent UART was completed. Click here for the RNBD code generation and compilation section.
The RNBD device can use Bluetooth (BT) Status Indication 1 and Bluetooth (BT) Status Indication 2 pins to indicate the GPIO connection status. Besides monitoring the connect message in the serial UART prints, this feature is useful when the host MCU can verify the BT connection status by monitoring the status indication pins.
Bluetooth (BT) Status Indication Pin Table:
Pin Mapping Between RNBD Bluetooth (BT) Status indication 1 and indication 2 Pins with PIC18F47Q10:
Pin Functionality | RNBD Pin Number | PIC18F47Q10 Pin Number |
---|---|---|
Bluetooth (BT) Status Indication 1 | PB3 | PC6 |
Bluetooth (BT) Status Indication 2 | PB7 | PC5 |
Configuration settings:
-
Select the GPIO based example and connection (Pin selection), as they are applicable for both the Basic Data Exchange and the Transparent UART application.
-
Pin selection for Status Indication 1 and 2 pins under the Pin Grid View tab:
-
Go to Pins, under Project Resources:
For Status Indication pins 1 and 2, Analog, Start High, Weak Pullup, Slew Rate and Input Level Control columns will be checked by default during the time of pin selection.
Deselect the checkboxes in the Analog, Start High, Weak Pullup, Slew Rate and Input Level Control columns.
Configuration for GPIO based connection was completed. Click here for the RNBD code generation and compilation section.
-
Click the Generate button next to Project Resources.
-
Include the header
#include "mcc_generated_files/examples/rnbd_example.h"
inmain.c
. -
Call the
RNBD_Example_Initialized();
function inmain()
afterSYSTEM_Initialize()
. -
Connect the development board of your choice and then connect the RNBD to the proper slot. The image below shows how to connect the RNBD Click to Slot 2.
Important: The slot was decided based on the UART instances which were configured for this example (see the pin mapping table between the MCU and the RNBD Click shown below).
-
Pin mapping Table between the MCU and RNBD Click
S. No Pin Functionality PIC RNBD Click 1 Receive (RxD) RB3 Tx 2 Transmit (TxD) RB0 Rx 3 BT_RST RC7 RST
-
-
Click Clean and Build.
-
Program the device by clicking the Make and Program button.
Basic Data Exchange:
This example shows how an MCU can be programmed to transmit data to a smartphone over BLE. The MCU device will send a Periodic Transmission of a single character when STREAM_OPEN is processed through the Message Handler. This indicates to the MCU and RNBD module that the application is in a Data Streaming mode of operation and can expect to hear data over the BLE connection.
The #define DEMO_PERIODIC_TRANSMIT_COUNT (10000)
and #define DEMO_PERIODIC_CHARACTER (‘1’)
statements used in the demonstration can be located at the top of the rnbd_example.c
file.
-
Download and install Microchip Bluetooth Data (MBD) from App Store or Google Play.
-
Launch the phone application.
-
The application scans the area for Bluetooth devices within a range. By default, the device should appear as "RNBD451_xxxx". Look for the "RNBD" device under scanned list.
-
Select the RNDB device from the list, then click the CONNECT button to connect to the RNDB module.
-
Once connected, the Microchip Bluetooth app identifies all the services and characteristics supported by the RNBD device.
-
Click the Microchip Data Service option. Select the Microchip Data Characteristic (Write Notify indication) to receive the data in the mobile application.
-
Select "Listen for notifications" on the application.
This example shows how the data transmitted from a PC serial terminal is written to a smartphone application and vice versa. The MCU acts as a bridge while passing data between RNDB module <--- MCU ---> Serial Terminal. This action will occur when STREAM_OPEN is processed through the Message Handler. For this example, data typed into the Serial Terminal will appear on the BLE phone application, and data sent from the application will appear on the Serial Terminal.
-
Download and install Microchip Bluetooth Data (MBD) from App Store or Google Play.
-
Launch the phone application
- Open the main menu and go to the BLE UART option
-
Select "PIC32CXBZ" to scan for available devices to connect with. The application automatically scans the area for Bluetooth devices within range. By default, the device appears as "RNBD451_xxxx".
-
For Transparent Serial only: Open a Serial Terminal Program such as Tera Term, Realterm, PuTTY, Serial or similar. Baud rate will be configured as 115200.
-
Once connected to RNBD451_0EC4, click "Text Mode" at the bottom of the settings to initiate the data transfer.
- Check the Serial Terminal for the status of the connection
-
Enter the text to be transferred from mobile to the RNBD45x device and click the Send button.
- The data will be received on the RNBD45x side and will be displayed in the serial terminal of RNBD45x
-
Type any data on the serial terminal of the RNBD45x to send to the Microchip Bluetooth Data app. The data is received and printed on the receive view of the app.
This section explains the RN487x MPLAB X IDE project setup, code generation, and shows how to run the Basic Data Exchange and Transparent UART applications with the PIC18F47Q10 microcontroller.
-
PIC18F47Q10 MCC Configuration - Basic Data Exchange Example
-
Set "Device Selection" to RN487x
-
Enable "Sample Examples"
-
Expand "Reference Examples" and select Basic Data Exchange
-
Notes:
-
Basic Data Exchange application uses only one instance of UART1 (PLIB ---> EUSART1) for data transfer.
-
Important: For EUSART Rx1 and Tx1 deselect the checkboxes in the Analog, Slew Rate and Input Level Control columns.
Configuration for PIC Basic Data Exchange was completed. Click here for the RN487x code generation and compilation section.
-
PIC18F47Q10 MCC Configuration - Transparent Serial Example
-
Set "Device Selection" to RN487x
-
Enable "Sample Examples"
-
Expand "Reference Examples" and select Transparent UART application
-
Notes:
- The Transparent UART application uses two instances of UART1 and UART2 (PLIB ---> EUSART1 and EUSART2) for data transfer.
- Important: For EUSART Rx1 and Tx1, deselect the checkboxes in the Analog, Slew Rate and Input Level Control columns.
Configuration for PIC Transparent UART was completed. Click here for the RN487x code generation and compilation section.
-
Click the Generate button next to Project Resources.
-
Include the header
#include "mcc_generated_files/examples/rnbd_example.h"
inmain.c
. -
Call the
RNBD_Example_Initialized();
function inmain()
afterSYSTEM_Initialize()
.
-
Connect the development board of your choice and then connect the RN487x to the proper slot. The image below shows how to connect the RN487x Click to Slot 2 as shown in below image.
Important: Slot was decided based on the UART instances which were configured for this example application (see the pin mapping table between the MCU and the RN487x Click shown below)
-
Pin Mapping Table between MCU & RN487x Click
S. No Pin Functionality PIC RN487x Click 1 Receive (RxD) RB3 Tx 2 Transmit (TxD) RB0 Rx 3 BT_RST RC7 RST
-
-
Click Clean and Build.
-
Program the device by clicking the Make and Program button.
This example shows how an MCU can be programmed to transmit data to a smartphone over BLE. The MCU device will send a Periodic Transmission of a single character when STREAM_OPEN is processed through the Message Handler. This indicates to the MCU and RN487x module that the application is in a Data Streaming mode of operation and can expect to hear data over the BLE connection.
The #define DEMO_PERIODIC_TRANSMIT_COUNT (10000)
and #define DEMO_PERIODIC_CHARACTER (‘1’)
statements used in the demonstration can be located at the top of the rn487x_example.c
file.
-
Download and install Microchip Bluetooth Data (MBD) from App Store or Google Play.
-
Launch the phone application.
-
The application automatically scans the area for Bluetooth devices within range. Look for the "RN487x" device under the scan list.
-
Select the RN487x device from the list, then click the CONNECT button to connect to the RN487x module.
-
Once connected, the Microchip Bluetooth app identifies all the services and characteristics supported by the RN487x.
-
Click the Microchip Data Service option. Select the Microchip Data Characteristic (Write Notify indication) to receive the data in the mobile application.
-
Select "Listen for notifications" on the application.
-
It may be required to enable app notifications on the phone. Data will be sent periodically to the device and will be visible beneath the Notify/Listen setting.
-
This example shows how the data transmitted from a PC serial terminal is written to a smartphone application and vice versa. The MCU acts as a bridge while passing data between RN487x module <--- MCU ---> Serial Terminal. This action will occur when STREAM_OPEN is processed through the Message Handler. For this example, data typed into the Serial Terminal will appear on the BLE phone application, and data sent from the application will appear on the Serial Terminal.
-
Download and install Microchip Bluetooth Data (MBD) from App Store or Google Play.
-
Launch the phone application
-
Select "BM70" to scan for available devices to connect with.
-
The application automatically scans the area for Bluetooth devices within range. By default, the device appears as "RN487x_xxxx".
-
-
For Transparent Serial only: Open a Serial Terminal Program such as Tera Term, Realterm, PuTTY, Serial or similar. Baud rate will be configured as 115200.
-
Once connected to RN487x-xxxx, click "Transfer data to device" to initiate the data transfer.
- Check the Serial Terminal for the status of the connection
-
Enter the text to be transferred from mobile to the RN487x-xxxx device and click the Send button.
- The data will be received on the RN487x side and will be displayed in the serial terminal of RN487x
-
Type any data on the serial terminal of the RN487x-xxxx to send to the Microchip Bluetooth Data app. The data is received and printed on the receive view of the app.
Command, Data Communication with Asynchronized Message Processing
This driver has the inherent code capability to distinguish between Message exchange and Data exchange at the level of the connected MCU and module devices. The library supplies all the APIs necessary for the implementation of a functional BLE-connected end-device. The three required pins can be selected through the GUI provided by the MCC. The two UART pins are used for communication and control of the RST_N connected to the RNBD/RN487x module. This library also allows for the extension of module pin behaviors through the simple RNBD module object interface, where any device/project specific instantiations exist. Refer to the rnbd_interface.c/h/rn487x_interface.c/h
file.
iRNBD_FunctionPtrs_t
is a typedef struct which can be found in the rnbd_interface.h/rn487x_interface.h
file and consists of nine function pointers. The concrete creation of RNBD as an object is instantiated in the rnbd_interface.c/rn487x_interface.c
. Find the private static implementations of the desired behavior in the rnbd_interface.c/rn487x_interface.c
file. In some cases, such as DELAY or UART, the supporting behavior is supplied through another supporting library module. When applicable, ‘inline’ has been used to reduce stack depth overhead.
The driver library may not require modifications or injections done by the user unless it expands to the supported command implementations rnbd.c
and rnbd.h
files.
Configurable Module Hardware Requirement(s):
The MCU and the module communicate through UART:
The library allows the configuration of three pins associated with support features extended through the Driver Interface. The RNBD modules require only the RESET pin to operate.
Library Name: Output(s) | Module: Input(s) | Description | Module Physical Defaults |
---|---|---|---|
BT_MODE | P2_0 | 1 : Application Mode0 : Test Mode/Flash Update/EEPROM Configuration |
Active-Low, Internal Pull-High |
BT_RST | RST_N | Module Reset | Active-Low, Internal Pull-High |
BT_RX_IND | P3_3 | Configured as UART RX Indication pin | Active-Low |