Microchip Technology ATBTLC1000 Xplained Pro Training manual

Type
Training manual
ATBTLC1000
Bluetooth® Low Energy Custom Service Implementation
Introduction
This document demonstrates how to use the ATBTLC1000 Bluetooth
®
Low Energy SoC by building a
custom specific profile using the Microchip BluSDK. This document includes the following topics:
Technical overview of the ATBTLC1000 board from hardware architecture to software design
Description of the required process for developing the Bluetooth Low Energy peripheral application
with the ATBTLC1000
Handling of Bluetooth Low Energy custom services and characteristics
Note:  The custom service implementation procedure uses the ATBTLC1000ZR-XSTK kit. This
procedure is also applicable for other supported platforms, as mentioned in BluSDK Release Notes.
Figure 1. Bluetooth Low Energy System Solution with ATBTLC1000
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 1
Table of Contents
Introduction......................................................................................................................1
1. Getting Started.......................................................................................................... 4
1.1. Software Prerequisites ................................................................................................................ 4
1.2. Software Setup.............................................................................................................................4
1.3. ATBTLC1000 Embedded Firmware............................................................................................. 5
1.4. ATBTLC1000 Host Software API................................................................................................. 5
1.5. Hardware Prerequisites................................................................................................................7
1.6. Hardware Setup........................................................................................................................... 9
2. Creating the Project and Initializing ........................................................................ 12
2.1. Creating Project from ASF......................................................................................................... 12
2.2. Configuring ASF for ATBTLC1000-ZR....................................................................................... 15
2.3. Compiling and Testing the Project..............................................................................................16
3. Establishing Connection with Central Device.......................................................... 18
3.1. Configuring and Starting the Advertisement Process.................................................................19
3.2. Managing GAP events............................................................................................................... 25
4. Setting/Handling of Pre-Defined Service ................................................................ 30
4.1. Adding Device Info Service Component from ASF Wizard to Project........................................ 31
4.2. Configuring and Loading Device Information Service................................................................ 33
5. Setting up and Handling Custom Service................................................................37
5.1. Configuring and Loading the Custom Environment Service.......................................................38
5.2. Updating the Temperature Characteristic...................................................................................43
6. Appendix A: Software Solution - Pre-Defined Svc ..................................................47
7. Appendix B: Software Solution - Custom Service................................................... 49
8. Document Revision History..................................................................................... 53
The Microchip Web Site................................................................................................ 54
Customer Change Notification Service..........................................................................54
Customer Support......................................................................................................... 54
Microchip Devices Code Protection Feature................................................................. 54
Legal Notice...................................................................................................................55
Trademarks................................................................................................................... 55
Quality Management System Certified by DNV.............................................................56
ATBTLC1000
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 2
Worldwide Sales and Service........................................................................................57
ATBTLC1000
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 3
1. Getting Started
This chapter describes the basic software and hardware requirements and setup.
1.1 Software Prerequisites
1.1.1 Installation Steps of Atmel Studio 7
1. Download and install the Atmel Studio software.
2. Install the Advanced Software Framework (ASF) package.
Note:  The software for ATBTLC1000-ZR is supported with ASF 3.35.1 and above.
Note:  For more information on the previous releases, refer to the Atmel Studio Release Notes available
on the Microchip web page.
1.2 Software Setup
1.2.1 Installation of Microchip SmartConnect application on a Mobile device
1. Open the Apple Store
®
(iPhone/iOS) or Google Play
Store (Android) on the mobile device.
2. Search for “Microchip SmartConnect”.
3. Click Install to install application on the device. The Microchip SmartConnect application is now
installed on the mobile device.
Figure 1-1. Microchip SmartConnect Dashboard
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 4
1.3 ATBTLC1000 Embedded Firmware
The management of Bluetooth Low Energy communication is based on the network stack stored in
ATBTLC1000 ROM. This stack requires parameters such as GAP parameters and attributes to be
functional, which are pushed from Host controller into ATBTLC1000 internal SRAM, using Generic
Transport Layer (GTL).
The ROM coded firmware embeds the layers of Bluetooth Low Energy stack v4.1 that runs on top of the
internal hardcoded peripheral drivers and RTOS scheduler.
Generic Access Profile (GAP)
GAP controls the Bluetooth Low Energy connection, advertising, makes the device visible to the
outside world, and determines how two devices interact with each other. GAP defines two main
roles for the Bluetooth Low Energy device, "Central" and "Peripheral".
Generic Attribute Profile (GATT) and Attribute Protocol (ATT)
GATT defines how the Bluetooth Low Energy device transfers the data. The GATT process is
based on services and characteristics stored in Attribute Protocol (ATT). ATT is a simple lookup
table stored in device SRAM.
Security Manager (SM)
The Security Manager defines the procedure for pairing, authentication and encryption between
BLE devices. This layer is mainly used if security is requested on that particular connection.
Logical Link Control and Adaptation Protocol (L2CAP)
L2CAP supports high-level protocol multiplexing, packet segmentation/reassembly, and conveying
the quality of service information. L2CAP permits applications to transmit and receive the data
packets with channel flow control and retransmission.
Direct test mode (DTM)
DTM allows testing of the radio's Physical Layer (PHY) by transmitting and receiving the test packet
sequences. This is often used in compliance and production line testing, without the need of going
through the complete Bluetooth Low Energy Protocol Stack.
1.4 ATBTLC1000 Host Software API
The ATBTLC1000 is provided with a dedicated Host software API layer. The purpose of this API layer is
to provide an easy and reliable solution to add Bluetooth Low Energy capabilities to any user application.
The API provides a set of high level Bluetooth function with abstraction of the transport protocol used
between the host MCU and the ATBTLC1000.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 5
Figure 1-2. Host Software API
Figure 1-3. BluSDK File Architecture
The API operation relies on a request-response mechanism. The specific requests are sent to
ATBTLC1000 through dedicated API function call. The event messages are then returned by the
ATBTLC1000 on request processing or on specific Bluetooth Low Energy events. These event messages
are to be handled by the host device, according to the user application requirements. The following figure
illustrates a typical Bluetooth Low Energy peripheral application flowchart.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 6
Figure 1-4. Bluetooth Low Energy Peripheral Application Flowchart
WARNING
The user application must be non-blocking to ensure that the Bluetooth Low Energy events are
handled in time.
1.5 Hardware Prerequisites
This document uses the ATBTLC1000ZR-XSTK kit. The ATBTLC1000ZR-XSTK kit is comprised of the
SAM L21 Xplained Pro (XPRO) and ATBTLC1000ZR XPRO extension board. The following sections
provide an overview of these kits and their features.
1.5.1 SMART
SAM L21 Xplained Pro
The SMART
SAM L21 Xplained Pro evaluation kit is used to evaluate the ATSAML21J18B
microcontroller. This kit includes an on-board embedded debugger to program and debug
ATSAML21J18B. The kit also contains an on-board current measurement circuitry, which enables the
user to measure current profile over time, without any external tools. The connection with any Xplained
Pro modules or external component is possible through available external connectors, which makes the
board perfect for prototyping the low-power applications.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 7
Figure 1-5. SAM L21 Xplained Pro Module
1.5.2 ATBTLC1000ZR Xplained Pro Extension board
The ATBTLC1000ZR Xplained Pro extension evaluation kit is based on Bluetooth Low Energy 4.1
compliant SoC ATBTLC1000-ZR110CA module. This extension is plugged to any of the supported host
MCU Xplained Pro evaluation boards, to quickly add Bluetooth Low Energy connectivity to the platform.
This kit provides easy access to the features of the ATBTLC1000-ZR110CA Bluetooth Low Energy
module and illustrates how to integrate the device in a custom design, which is supported by the Atmel
Studio integrated development platform.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 8
Figure 1-6. ATBTLC1000ZR Xpro Board
The ATBTLC1000ZR Xplained Pro extension board contains:
ATBLTC1000-ZR110CA Module – Bluetooth Low Energy module with 2.4 GHz, Bluetooth Low
Energy 4.1 compliant ATBTLC1000-XR1100A SiP
AT30TSE758A Digital Temperature Sensor – Integrated temperature sensor with nonvolatile
registers and serial EEPROM. Compatible with two-wire (I
2
C) and SMBus serial interfaces
Current Measurement Header – Allows measurement of the current consumption of the board. It
must be closed to enable power to the ATBTLC1000-ZR110CA module
1.6 Hardware Setup
1. Ensure that ATBTLC1000ZR-XPRO power consumption header is closed and that jumpers are
placed on pins 2 to 3 of headers J105, J106, J107 and J108, as shown in the following figure.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 9
Figure 1-7. ATBTLC1000ZR-XPRO Extension
2. Connect the ATBTLC1000ZR-XPRO extension to EXT1 of SAM L21 XPRO, as illustrated in the
following figure.
Figure 1-8. ATBTLC1000ZR-XPRO Extension connected with SAM L21 XPRO
3. Connect the board to PC using the “Debug USB Connector”.
Figure 1-9. SAM L21 XPRO Connection to PC
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 10
4. Now, the Hardware is ready for development.
ATBTLC1000
Getting Started
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 11
2. Creating the Project and Initializing
This chapter provides the process of creating an application startup project using Atmel Studio. Prior to
creating a project, the user must know hardware architecture and software requirements to configure
drivers.
The hardware connection between the SAM L21 XPRO and the ATBTLC1000ZR XPRO board is
illustrated in following figure. This SAM L21 board is used as host MCU.
Figure 2-1. ATBTLC1000ZR Xpro Board Connection with SAM L21
Note:  For more details, refer to module datasheet and XPRO board design documentation.
2.1 Creating Project from ASF
Advanced Software Framework has a pre-configured Bluetooth Low Energy Startup template project that
includes Bluetooth Low Energy software API for Host and ATBTLC1000, and their peripheral driver
dependencies. This is used as starting project for any Bluetooth Low Energy project development.
To create the project, follow the steps below:
1. Search for the “BLE-Startup Template” from the New Example Project from ASF menu in Atmel
Studio.
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 12
Figure 2-2. Advanced Software Framework_New Example Project
Note:  ATBTLC1000/SAMB11 related projects are prefixed with “BLE”, making it easier to filter the
project in the dialogue box.
2. Select the appropriate “BLE-Startup Template” project corresponding to the intended Host MCU
Xplained Pro board and then press OK button to import the BLE startup template project. Select
“BLE-Startup Template – SAM L21 Xplained Pro SAML21J18B,” for this hands-on.
Note:  Rev B XPRO boards can be identified by SAML21J18B silk screen marking below SAML21
MCU.
3. The BLE startup project is now created and loaded in Atmel Studio.
Figure 2-3. Startup_Template Project
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 13
Note:  The main project routine of “Startup Template project” already includes host MCU low level
initialization, BLE and ATBTLC1000 initialization. The added ASF components in project can be
viewed from “ASF>ASF Wizard”. Select the created project from "Project" drop down box.
Figure 2-4. ASF Wizard Window
BLE_STACK Platform Interface – Core manager of Bluetooth Low Energy Host API. It
manages ATBTLC1000 device initialization, GAP and GATT events
Timer Driver – Task timer functionality by using a Timer Counter (TC) or Timer Counter for
Control (TCC) peripheral
Console UART – Universal Asynchronous Receiver/Transmitter (UART) communication in
synchronous/blocking mode
Generic Board Support – Host MCU Board specific initialization
System Drivers – Select MCU’s System peripheral drivers. These drivers are included by
default in ASF projects and manage the clocks and oscillator of the system
4. The main routine contains the MCU low level initialization and ATBTLC1000 initialization. The
following figure illustrates the flowchart of the main routine.
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 14
Figure 2-5. Main Routine Flowchart
2.2 Configuring ASF for ATBTLC1000-ZR
1. The default “Startup Template Project” is configured for ATBTLC1000-MR module with 6-Wire
mode.
2. Navigate to Project properties: Project > Project properties > Toolchain > ARM/GNU C Compiler >
Symbols.
3. The ATBTLC1000ZR-XSTK kit uses the ATBTLC1000-ZR110CA module. Change symbol
BLE_MODULE to BTLC1000_ZR and enable UART_FLOWCONTROL_4WIRE_MODE for
ATBTLC1000-ZR module, as shown in the figure below.
Figure 2-6. Startup Template Project Window
Note:  This configuration change is not required for ATBTLC1000-MR module.
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 15
2.3 Compiling and Testing the Project
1. Click the “ ” button <F7> to compile the project.
2. Verify that no build error appears in Atmel Studio output window.
Figure 2-7. Atmel Studio Output Window
3. Connect the SAM L21 XPRO to PC (if not already done).
4. To access the project properties, go to Project >
STARTUP_TEMPLATE_SAML21_XPLAINED_PRO_B1 Properties.
Figure 2-8. Compiling the Project
5. In project properties, click the Tool tab, and select the EDBG of SAM L21 Xplained Pro board as
debugger/programmer.
Figure 2-9. Selection of Debugger/Programmer
6. Open any Terminal application (for example, TeraTerm). Select the COM port enumerated on the
PC and set the following parameters:.
EDBG associated COM Port (Check Windows Device Manager)
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 16
Baudrate 115200
Parity None
One Stop bit
Enable Hardware Flow Control
7. Click " " to save the project <Ctrl+S>.
8. Click " ” to program the project binary on the SAM L21 Xplained Pro. <Ctrl+Alt+F5>.
9. The initialization of the ATBTLC1000ZR module must return the Bluetooth Device Address and
Address type.
Figure 2-10. Console Log Window
Note: 
1. If initialization fails, make sure to verify the hardware configuration is aligned with the
description, refer to Hardware Setup.
2. The initialization of ATBTLC1000 takes few seconds, due to patch download process.
ATBTLC1000
Creating the Project and Initializing
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 17
3. Establishing Connection with Central Device
The Bluetooth Low Energy connectivity is added to the application that is used to connect with the
Bluetooth Low Energy central. The first step is about the management of Bluetooth connection with a
central device. When using ATBTLC1000 device, this process is managed by dedicated API function calls
associated with ATBTLC1000 events handling.
The interaction between Host MCU, ATBTLC1000 and Bluetooth Low Energy central during connection
establishment is as follows:
Figure 3-1. Establishing Connection with Central Device
On host MCU side, the management of the Bluetooth connection is performed through three main steps.
1. GAP callback registration
2. Advertisement configuration
3. ATBTLC1000 event handling
In the existing project main routine, the integration of these steps are highlighted in red in the following
flowchart.
ATBTLC1000
Establishing Connection with Central Device
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 18
Figure 3-2. Main Routine Flow Chart
3.1 Configuring and Starting the Advertisement Process
The Bluetooth Low Energy devices transmit advertisement packets to show their presence to nearby
devices. The advertisement packet is sent periodically at a time interval defined by variable
advinterval” defined in Bluetooth SIG specification. To avoid any collision with other wireless network
such as Wi-Fi
®
, a channel change is performed for each advertisement packet sent (data frequency
hopping), as illustrated in the following figure.
Figure 3-3. Advertisement Process
During advertisement, the payload structure to be sent differs from application to application and is set by
using encapsulated packet data unit type information (PDU_TYPE).
ATBTLC1000
Establishing Connection with Central Device
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 19
Figure 3-4. PDU Advertising
The following table lists the different PDU types used according to device role.
Advertising event types (PDU_TYPE) Broadcaster Observer Peripheral Central
Connectible undirected event (ADV_IND)
Excluded Excluded Mandatory Excluded
Connectible directed event
(ADV_DIRECT_IND)
Excluded Excluded Optional Excluded
Non-connectible undirected event
(ADV_NONCONN_IND)
Mandatory Excluded Optional Excluded
Scannable undirected event (ADV_SCAN_IND)
Optional Excluded Optional Excluded
As our device acts as a Bluetooth Low Energy peripheral, the "connectable undirected event (ADV_IND)"
advertising type is used. See the following description about the ADV_IND advertisement packet.
Figure 3-5. ADV_IND Advertisement Packet
The ADV_IND payload contains different Advertisement Data types (AD0 - ADn), which provide specific
information to the central device such as "device short name", "Tx power level" and "list of available
services UUIDs". The number of advertisement data types that can be added to the advertisement
payload are limited by the advertisement payload size of 31 octets.
Following is a list of advertisement data types that are commonly found in ADV_IND payload.
ATBTLC1000
Establishing Connection with Central Device
© 2017 Microchip Technology Inc.
Training Manual
DS00002599A-page 20
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57

Microchip Technology ATBTLC1000 Xplained Pro Training manual

Type
Training manual

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI