This application note describes how to transmit sensor (Renesas HS3001 Humidity and Temperature
Sensor) information via Bluetooth using the RL78/G14 Fast Prototyping Board and the RL78/G1D BLE
Module Expansion Board.
The Host Sample is a Host MCU program executed by the RL78/G14 Fast Prototyping Board using the
Bluetooth low energy protocol stack modem configuration. Controls the RL78/G1D Module on the RL78/G1D
BLE Module Expansion Board connected by the UART 2-wire branch connection. It can also save pairing
and pairing information with the Security Library.
This document also describes the hardware configuration that runs the Host Sample, the software
configuration, the procedure for checking the smartphone and communication, and the Bluetooth
communication sequence.
Target Device
RL78/G14 Fast Prototyping Board (Parts Number: RTK5RLG140C00000BJ)
RL78/G1D BLE Module Expansion Board (Parts Number: RTKYRLG1D0B00000BJ)
Related Documents
R01AN4834EJ0120 Rev.1.20 Page 1 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
4. How to Build .......................................................................................................................... 16
4.1 CS+ for CC ............................................................................................................................................ 16
4.2 e2 studio ................................................................................................................................................. 16
4.3 Writing HEX file using Renesas Flash Programmer ............................................................................. 17
5.2.1 CS+ for CC .......................................................................................................................................... 19
5.2.2 e2 studio ............................................................................................................................................... 19
5.3 Communication operation check using a smartphone .......................................................................... 20
6.1 rBLE Command and rBLE Event ........................................................................................................... 24
6.2 Main Loop .............................................................................................................................................. 25
6.3 GPCP Transmission/Reception Function .............................................................................................. 26
6.3.1 Transmit Function ................................................................................................................................ 26
6.3.2 Receive Function ................................................................................................................................. 27
6.4.1 Transmission Process ......................................................................................................................... 28
6.4.2 Reception Process .............................................................................................................................. 29
Revision History ............................................................................................................................ 41
The Bluetooth
®
word mark and logos are registered trademarks owned by Bluetooth SIG, Inc. and any use of
such marks by Renesas Electronics Corporation is under license. Other trademarks and registered
trademarks are the property of their respective owners.
TM
Pmod
is registered to Digilent Inc.
R01AN4834EJ0120 Rev.1.20 Page 3 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
1. Overview
This application note describes how to transmit sensor information via Bluetooth using the RL78/G14 Fast
Prototyping Board and the RL78/G1D BLE Module Expansion Board. The sensor uses the Renesas HS3001
Humidity and Temperature Sensor Module (humidity, temperature).
The Host Sample is a Host MCU program that runs on the RL78/G14 Fast Prototyping Board using the
Bluetooth Low Energy Protocol Stack (BLE Protocol Stack) Modem configuration. Controls the RL78/G1D
module (RY7011) that configures the RL78/G1D BLE Module Expansion Board of the BLE MCU connected
by UART 2-wire branch connection
and pairing information can be saved in the RL78/G14 Fast Prototyping Board.
)
(Note1
. In addition, by using the Security Library
(Note2)
, pairing execution
The module firmware for operation check is written in RY7011 at the factory, and can be controlled from the
(Note3)
Host MCU program using the rBLE API
of the BLE protocol stack.
Notes: 1. In addition to TxD and RxD, which are UART data signal lines, the Host MCU has a WAKEUP
signal line for waking up the BLE MCU at the time of data transmission. The WAKEUP signal line
branches TxD of Host MCU and connects with WAKEUP of BLE MCU. For connection between
Host MCU and BLE MCU, refer to "6.4.3 Application Circuits".
®
2. For details on the Security Library, refer to the "Bluetooth
Low Energy Protocol Stack Security
Library" (R01AN3777).
3. For details on the BLE protocol stack API, refer to the "Bluetooth® Low Energy Protocol Stack API
Reference Manual : Basics" (R01UW0088).
R01AN4834EJ0120 Rev.1.20 Page 4 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
2. Development Environment
Describes the build environment and the development environment used to operation check.
2.1 Hardware Environment
Host
• PC/AT
• Processor: 1GHz or faster (with support for hyper threading and multicore CPUs)
• Main Memory: We recommend 2GB or more.
• Display: Graphics resolution should be at least 1024 x 768, and the mode should display at least
• Interface: USB2.0
Development Board
• RL78/G14 Fast Prototyping Board (RTK5RLG140C00000BJ)
• RL78/G1D BLE Module Expansion Board (RTKYRLG1D0B00000BJ)
• Renesas HS3001 Humidity and Temperature Sensor Module with I2C Interface
Smartphone
• Android device or iOS device
TM
compatible computer
65,536 colors.
2.2 Software Environment
OS
• Windows7 or later
Integrated Development Environment/Compiler
Use one of the following integration environment and compiler combinations.
• CS+ for CC V8.05.00 / CC-RL V1.10.00
2
• e
studio 2021-01 (64-bit version) / CC-RL V1.10.00
2
• e
studio V7.8.0 (32-bit version) / CC-RL V1.10.00
R01AN4834EJ0120 Rev.1.20 Page 5 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
RL78/G14
Fast Prototyping Board
RL78/G1D BLE Module
Expansion
Renesas HS3001
Humidity and Temperature
Sensor Module
Smartphone
PMOD1
PMOD
Local Device (Peripheral)
Remote Device (Central)
Mic ro
USB
RX231
ELED
LED_P
Coin cell
battery holder
Pmod
Connec ter 2
Pmod
Connec ter 1
LED0
RESET
SW
User’ s
SW
LDO
10 Pin socket
8 Pin soc ket
8 Pin soc ket
6 Pin soc ket
RL78/G14
80-LFQFP
LED1
Pmod
conn ecter
RL78/G1D
BLE Module
X
1
C2
C3
C1
R1
R2
Pmod
conn ecter
HS3001
Pmod
conn ecter
3. Host Sample Compositions
3.1 Device Compositions
"Figure 3-1 Device Compositions" shows the device configuration diagram used in this application note.
The Local Device (Peripheral) consists of the RL78/G14 Fast Prototyping Board, which is the Host MCU, and
the RL78/G1D BLE Module Expansion Board, which is the BLE MCU. The two boards are connected by
PMOD1 and communicate via UART 2-wire branch connection. Also, to transmit sensor data from the
RL78/G1D BLE Module, connect Renesas HS3001 Humidity and Temperature Sensor Module (humidity,
temperature) to PMOD2
Remote Device (Central) uses the smartphone of Android device or iOS device.
Note
of the RL78/G14 Fast Prototyping Board. PMOD2 communicates over IICA.
Board
2
Note
Figure 3-1 Device Compositions
Note: Connect to PMOD2 when using the I2C communication Pmod
TM
module. Then change the pin that
assigns the function of serial interface IICA with the peripheral I/O redirect function of RL78/G14.
Refer to "Table 3-2 PMOD2 connector pin assignment" for pin assignment.
The overview of the host sample is shown below.
It uses rBLE API and executes below operations.
• After power up, it starts broadcasting.
• Connection is established by the connection request from Remote Device.
• It executes pairing and starting encryption if Remote Device requires.
• Enable the General Purpose Communication Profile with Indication permission from Remote
Device.
• Erase the security information stored in the data flash with the USER SW.
It is implemented a simple scheduler for management processing sequence.
It changes the RL78/G14 state into the STOP mode if there is nothing to execute.
It supposes that peer device is a smart phone (Android device or iOS device).
(Tablet)
R01AN4834EJ0120 Rev.1.20 Page 6 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
RL78/G14 Fast Prototyping Board
PmodTM
RL78/G1D BLE Module Expansion Board
Function Name
Pin No.
Pin No.
Pin No.
Function Name
P74/KR4/INTP8
33 1 2
P30/INTP3/RTC1HZ
P51/INTP2/SO00/TxD0/TOOLTxD/TRGIOB
42 2 8
P11/SI00/RxD0/TOOLRxD/SDA00/(TI06)/(TO06)
P50/INTP1/SI00/RxD0/TOOLRxD/SDA00/TRGIOA/(TRJO0)
41 3 7
P12/SO00/TxD0/TOOLTxD/(TI05)/(TO05)
P30/INTP3/RTC1HZ/SCK00/SCL00/TRJO0
40 4 9
P10/SCK00/SCL00/(TI07)/(TO07)
GND
- 5 -
GND
VCC
- 6 -
VDD
P140/PCLBUZ0/INTP6
2 7 -
N.C
P130
72 8 24
RESET#
P147/ANI18/VCOUT1
58 9 -
N.C
P146
57
10
23
P40/TOOL0
GND
-
11
-
GND
VCC
-
12
-
VDD
RL78/G14 Fast Prototyping Board
PmodTM
Renesas HS3001 Humidity and Temperature Sensor Module
Function Name
Pin No.
Pin No.
Function Name
P16/TI01/TO01/INTP5/TRDIOC0/IVREF0/(SI00)/(RxD0)
48
1
NC
P13/TxD2/SO20/TRDIOA1/IVCMP1
51
2
NC
(
)P14/RxD2/SI20/SDA20/TRDIOD0/(SCLA0)
50
3
SCL
(
)P15/SCK20/SCL20/TRDIOB0/(SDAA0)
49
4
SDA
GND
- 5 VSS
VCC
- 6 VDD
P141/PCLBUZ1/INTP7
1 7 NC
P110/(INTP11)
55
8
NC
P17/TI02/TO02/TRDIOA0/TRDCLK/IVCMP0/(SO00)/(TxD0)
47
9
NC
P111
56
10
NC
GND
-
11
VSS
VCC
-
12
VDD
3.1.1 PmodTM Interface
The PmodTM interface connector pin assignments in "Figure 3-1 Device Compositions" are shown. The
function used by each pin is shown in blue.
(1) PMOD1
Table 3-1 PMOD1 connector pin assignment
(2) PMOD2
Table 3-2 PMOD2 connector pin assignment
Note
Note
Note: Change the function assignment of RL78/G14 with the peripheral I/O redirect function. Connect to
TM
PMOD2 when using the I2C communication Pmod
module.
3.1.2 User Switch (SW_USR)
Erases the security information of the RL78 / G14 data flash.
For security information, refer to "Bluetooth
R01AN4834EJ0120 Rev.1.20 Page 7 of 41
Mar.2.21
®
Low Energy Protocol Stack Security Library" (R01AN3777).
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
The software composition of RL78/G14 which is a Host MCU and RY7011 which is a BLE MCU is shown.
Firmware for operation check is written in RY7011 at the time of shipment, and it supports some profiles. In
this document, General Purpose Communication Profile (GPCP) is used. For other profiles, refer to "7.
Profile" in the "RL78/G1D Module Firmware User's Manual" (R01UW0160).
Figure 3-2 Software Compositions
The software of Host MCU consists of low level peripheral drivers and peripheral drivers which controls MCU
peripheral hardware, RSCIP (Renesas Serial Communication Interface Protocol), rBLE_Host which provides
rBLE APIs, host application which controls the system, General Purpose Communication Profile (GPCP)
using the GATT API, Security Library that provides security functions such as pairing.
Low Level Peripheral driver code is generated by the Code Generator. RSCIP and rBLE_Host are included
in BLE protocol stack package and provided code. When developing software, it is necessary to use the
latest code which is provided by BLE protocol stack package.
Communication Profile
Notes: 1. Code files for software development are provided by BLE protocol stack package.
2. Code files for software development are generated by the Code Generator.
R01AN4834EJ0120 Rev.1.20 Page 8 of 41
Mar.2.21
Table 3-3 Host MCU Software Composition
Scheduling rBLE command execution
(provided by package)
Note2
Note1
Note1
Note1
Note1
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
Software
Functions
Modem Application
Controlling RSCIP and rBLE
RWKE
Managing the whole system schedule and memory resource.
RSCIP
Controlling serial communication
Peripheral Driver/Serial Driver
Controlling BLE MCU peripheral hardware
rBLE_Core
Providing rBLE APIs
Profile
Providing Profiles functions
Host Stack
Providing GAP, GATT, SM, L2CAP functions
GSCP GATT Database
GATT Database of General Purpose Communication Profile
Controller Stack
Providing LL functions
The software of BLE MCU consists of RF driver which controls RF/BB, Host/Controller stacks, Profiles,
rBLE_Core, Serial Driver and RSCIP for communicating with Host MCU, RWKE (Renesas Wireless Kernel
Extension) which manages the system and Modem application. The build environment is provided by
"RL78/G1D Module Module Control Software" (R01AN3362).
Table 3-4 BLE MCU Software Composition
R01AN4834EJ0120 Rev.1.20 Page 9 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
Peripheral Function
Purpose
Necessity
Note
Pin assignment
Used for IICA communication between the RL78/G14 Fast
Optional
Clock generator
Used to set the operating frequency of RL78/G14.
Mandatory
Port
P74: Used as WAKEUP pin of UART 2-wire branch
Mandatory
P43: Used for LED0 of RL78/G14 Fast Prototyping Board.
Optional
Serial-UART0
Used for UART communication between RL78/G14 Fast
Mandatory
Serial-IICA0
Used for IICA communication between RL78/G14 Fast
Optional
Timer-TAU0
Used for A/D conversion wait time of Renesas HS3001
Optional
12-bit Interval timer
Used for the rBLE timer function.
Mandatory
Interrupt Functions -
Used for interrupting the user switch (SW_USR).
Optional
3.3 Peripheral Function Compositions
The following shows the RL78/G14 peripheral functions used on the RL78/G14 Fast Prototyping Board.
Table 3-5 Peripheral Functions
(Peripheral I/O redirect
function)
Prototyping Board and the Renesas HS3001 Humidity and
Temperature Sensor Module.
At reset of RL78/G14, IICA0 pin is assigned to SCLA0=P60
and SDAA0=P61. Communication can be performed with
IICA0 by assigning SCLA0=P14 and SDAA0=P15 to the
PMOD2 I/F of the RL78/G14 Fast Prototyping Board with
the peripheral I/O redirect function.
connection with RL78/G1D BLE Module Expansion Board.
P130: Used as reset release pin of RL78 / G1D BLE Module
Expansion Board.
P44: Used for LED1 of RL78/G14 Fast Prototyping Board.
Prototyping Board and RL78/G1D BLE Module Expansion
Board.
Prototyping Board and Renesas HS3001 Humidity and
Temperature Sensor Module.
Humidity and Temperature Sensor Module.
INTP0
Note: Peripheral hardware which Host MCU required to use the rBLE is classified "Mandatory", other
peripheral hardware is classified "Optional".
R01AN4834EJ0120 Rev.1.20 Page 10 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
Peripheral Function
Purpose
Setting
Port assignment
PIOR2
Set to 1
Clock generator
mode
High-speed main mode
EVDD
1.8(V)≦EV
5.5(V)
High-speed on-chip
64(MHz)
Low-speed on-chip
15kHz
RTC, interval timer clock
15(fIL)kHz
CPU/peripheral hardware
32000(fIH)kHz
Port
P43
Output
P44
Output
P74
Output
P130
Output
Serial
Data bit length
8 bit
Data direction
LSB
Parity
no parity
Stop bit length
1 bit
Data phase
standard
Baudrate
115200(bps)
Interrupt (INTSR0)
High
Callback function
Reception transfer end
Serial
Transfer mode
Single mode
Data bit length
8 bit
Data direction
LSB
Parity
no parity
Stop bit length
1 bit
Data phase
standard
Baudrate
115200(bps)
Interrupt (INTST0)
Low
Table 3-6 Peripheral Functions Setting
(Peripheral I/O redirect
function)
oscillator
oscillator
clock
(Assign SCLA0 to P14)
(Assign SDAA0 to P15)
2.7(V)≦VDD≦5.5(V)
≦
DD
(RL78/G14 Fast Prototyping Board LED0)
(RL78/G14 Fast Prototyping Board LED1)
(RL78/G1D BLE Module Expansion Board
WAKEUP pin)
SAU0 - UART0 - Receiving
SAU0 - UART0 - Transmitting
(RL78/G1D BLE Module Expansion Board
RESET pin)
Error
R01AN4834EJ0120 Rev.1.20 Page 11 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
Callback function
Transmission end
Serial
Count clock
f
/2
Own address
16
Mode
standard
Transmission clock
100000(bps)
Transmission completion
Low
Callback function
Master transmission completion
Callback extension function
Master transmission/reception callback
Timer
Interval period
1ms
Interrupt setting
count completion interrupt
Priority
Low
12-bit interval timer
Interval timer
used
Interval period
10ms
Interrupt
interval period expiration interruption
Priority
Low
Interrupt
Valid edge
Falling edge
Priority
Low
CLK
IICA0 - Single master
interrupt priority (INTIICA0)
Master reception completion
Master error
with stop condition generation
TAU0 - channel 0- Interval
timer
(INTTM00)
INTP0 - External interrupt
(INTIT)
R01AN4834EJ0120 Rev.1.20 Page 12 of 41
Mar.2.21
Bluetooth® Low Energy Protocol Stack Fast Prototyping Board Host Sample
RL78G14_Fast_Prototyping_Board_HostSample
HostSample
Platform
driver
hs3001
r_hs3001.c
Renesas HS3001 driver code file
r_hs3001.h
Renesas HS3001 driver header file
serial
uart.c
UART driver code file
uart.h
UART driver header file
dataflash
dataflash.c
Dataflash driver code file
dataflash.h
Dataflash driver header file
eel_descriptor_t02.c
EEPROM Emulation Library driver code file
eel_descriptor_t02.h
EEPROM Emulation Library driver header file
fdl_descriptor_t02.c
Data Flash Access Library driver code file
fdl_descriptor_t02.h
Data Flash Access Library driver header file
cc_rl
eel.h
EEPROM Emulation Library API header file
eel.lib
EEPROM Emulation Library
eel_types.h
EEPROM Emulation Library Type header file
fdl.h
Data Flash Access Library API header file
fdl.lib
Data Flash Access Library
fdl_types.h
Data Flash Access Library Type header file
timer
timer.c
timer driver code file
timer.h
timer driver header file
include
arch.h
(R)
architecture header file
compiler.h
(R)
compiler header file
ll.h
(R)
low level macro header file
rscip_api.h
(R)
RSCIP callback header file
types.h
(R)
type definition header file
rBLE
├─host
│ │ rble_host.c
(R)
rBLE_Host code file
│ │ rble_if_api_cb.c
(R)
rBLE API callback code file
│ │
│ ├─gap
│ │ rble_api_gap.c
(R)
GAP API code file
│ │
│ ├─gatt
│ │ rble_api_gatt.c
(R)
GATT API code file
│ │
│ ├─sm
│ │ rble_api_sm.c
(R)
SM API code file
│ │
│ └─vs
│ rble_api_vs.c
(R)
VS API code file
3.4 File Compositions
The file composition of the host sample is shown below.
The (R) mark of file configuration indicates that the file is included in the BLE protocol stack package. When
developing software, it is necessary to use the latest code which is provided by BLE protocol stack package.