- 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.
- 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 AVR® 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 MPLABX 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)
-
AVR128DA48 Product Page (AVR128DA48)
-
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 AVR128Dx28/32/48/64, AVR64Dx28/32/48/64 Microcontrollers (MCUs)
-
MPLAB Code Configurator Device Libraries AVR® MCUs
-
Microchip AVR-Dx_DFP Series Device Support (2.5.294) or newer
-
Pin mapping table between the MCU and the RNBD Click:
S. No Pin Functionality AVR RNBD Click 1 Receive (RxD) RA1 Tx 2 Transmit (TxD) RA0 Rx 3 BT_RST RD7 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 1.
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 AVR RN487x Click 1 Receive (RxD) RA1 Tx 2 Transmit (TxD) RA0 Rx 3 BT_RST RD7 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 1.
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. AVR128DA48 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.
-
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.
-
Generating example applications:
-
Clock Settings:
-
UART Settings:
-
Global Interrupt 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 AVR128DA48 microcontroller.
-
AVR128DA48 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 USART0 for data transfer.
-
Important: For USART0 RxD and TxD, deselect the checkboxes in the Start High and Pull-Up columns. Change Rx, Tx and BT_RST in the Input/Sense Configuration [ISC] column from "Interrupt Disabled but input buffer enabled" to "Sense Both Edges".
Configuration for AVR Basic Data Exchange was completed. Click here for the RNBD Code Generation and Compilation section.
-
AVR128DA48 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 instance USART0 and USART1 for data transfer.
-
Important: For USART0 and USART1 RxD and TxD, deselect the checkboxes in the Start High and Pull-Up columns. Change Rx, Tx and BT_RST in the Input/Sense Configuration [ISC] column from "Interrupt Disabled but input buffer enabled" to "Sense Both Edges".
Configuration for AVR Transparent UART was completed. Click here for 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 the RNBD Bluetooth (BT) Status Indication 1 and Indication 2 pins with AVR128DA48:
Pin Functionality | RNBD Pin Number | AVR128DA48 Pin Number |
---|---|---|
Bluetooth (BT) Status Indication 1 | PB3 | PA6 |
Bluetooth (BT) Status Indication 2 | PB7 | PA5 |
-
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, the checkboxes in the Default Start High, Pull-Up columns will be checked.
Deselect the checkboxes in the Start High and Pull-Up columns. Change Rx and Tx in the Input/Sense Configuration [ISC] column from "Interrupt Disabled but input buffer enabled" to "Sense Both Edges".
Configuration for GPIO based connection was completed. Click here for the RNBD Code Generation and Compilation section.
-
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 1.
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 MCU and RNBD Click
S. No Pin Functionality AVR RNBD Click 1 Receive (RxD) RA1 Tx 2 Transmit (TxD) RA0 Rx 3 BT_RST RD7 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 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 range. By default, the device appears as "RNBD451_xxxx". Look for the "RNBD" device under the scan list.
-
Select the RNBD device from the list, then click the CONNECT button to connect to the RNBD 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.
-
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.
-
Before turning on the Notify/Indicate setting:
-
After turning on the Notify/Indicate setting, the mobile application can read "31", data which was sent from the RNBD module
-
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 RNBD 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 RNBD device and click the Send button.
- The data will be received on the RNBD side and will be displayed in the serial terminal of RNBD45x
-
Type any data on the serial terminal of the RNBD 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 AVR128DA48 microcontroller.
-
AVR128DA48 MCC Configuration - Basic Data Exchange Example
-
Set "Device Selection" to RN487x
-
Enable "Sample Examples"
-
Expand "Reference Examples" and select Basic Data Exchange
-
Notes:
-
The Basic Data Exchange application uses only one instance of USART0 for data transfer.
-
Important: For USART0 RxD and TxD, deselect the checkboxes in the Start High and Pull-Up columns. Change Rx, Tx and BT_RST in the Input/Sense Configuration [ISC] column from "Interrupt Disabled but input buffer enabled" to "Sense Both Edges".
Configuration for AVR Basic Data Exchange was completed. Click here for RN487x code generation and compilation section.
-
AVR128DA48 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 instance of USART0 and USART1 for data transfer.
- Important: For USART0 and USART1 RxD and TxD, deselect the checkboxes in the Start High and Pull-Up columns. Change Rx,Tx and BT_RST in the Input/Sense Configuration [ISC] column from "Interrupt Disabled but input buffer enabled" to "Sense Both Edges".
Configuration for AVR Transparent UART application 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/rn487x_example.h"
inmain.c
. -
Call the
RN487X_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 1.
Important: The slot was decided based on the UART instances which was configured for this example application (see the pin mapping table between the MCU and the RN487x Click shown below).
-
Pin mapping table between MCU and RN487x Click
S. No PIN Functionality AVR RN487x Click 1 Receive (RxD) RA1 Tx 2 Transmit (TxD) RA0 Rx 3 BT_RST RD7 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 scan 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 RNBD module.
-
Once connected 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.
-
Click the 'Scan image' icon to scan for the nearby "RN487x-xxxx"
-
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 required APIs needed 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 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 |