Getting Started with Bluetooth Low Energy (2014)
Chapter 5. Hardware Platforms
Most commercial use cases for BLE-enabled products involve peripherals, rather than the central devices (phones, tablets, or personal computers) you would design products to interact with. As such, this chapter introduces some specific development platforms for designing and prototyping BLE peripherals.
The discussion in this chapter assumes a basic familiarity with embedded system design (Chapter 10), and the primary goal is to point product designers to inexpensive and readily available platforms that might be appropriate for their products.
nRF51822-EK (Nordic Semiconductors)
Nordic Semiconductors has been involved in low-power wireless solutions for years and, as a board member on the Bluetooth SIG, has helped define and shape the core BLE standard since its inception. Widely known in the wireless market for its popular, general-purpose radio-frequency (RF) silicon solutions, it was one of the first companies to get affordable BLE peripheral-mode silicon to market (the nRF8001). Its newest nRF51 family represents a complete redesign from many of their previous single-chip RF products, combining a radio with a modern 32-bit ARM microprocessor in a single chip.
Nordic’s nRF51 series is a highly integrated system-on-chip, combining a BLE-compatible radio and a modern ARM processor in a single low-cost package with the following characteristics:
§ ARM Cortex-M0 core running at 16 MHz
§ 128 or 256 KB flash memory (between 80 and 90 KB is required for the S110 BLE stack)
§ 16 KB SRAM (8 KB available to the application with the S110 BLE stack)
Being an entirely flash-based device is a key distinguishing factor of the nRF51822 for product designers. This means that the BLE stack is written into modifiable flash memory and can be updated as the core spec evolves, without necessarily requiring a new silicon revision.
The down side of this choice is that it adds some additional per-device manufacturing costs, compared to a ROM-based solution. But given the fast-paced development of the Bluetooth Core Specification, the gamble might pay off in the long run, because it gives Nordic the potential to get to market with support for the latest spec faster than other silicon vendors who have opted for lower-cost ROM-based chips.
In order to implement BLE support on its chips (which can also be used for non-BLE standards, such as ANT+ and proprietary 2.4GHz protocols), Nordic makes use of something it calls a SoftDevice (SD). The SoftDevice is essentially a black box that sits in the bottom part of flash memory and implements features such as the BLE stack and peripheral role support. The user (application) code sits at a higher address in flash memory and makes calls to this lower-level SoftDevice as appropriate.
Most BLE products use the S110 SoftDevice, which is a peripheral-only solution. The device architecture also includes a S120 SoftDevice that supports the central role, but because that use-case is less common for BLE, the discussion in this section will focus on the S110.
Nordic’s SoftDevice design approach has its benefits and drawbacks. On the positive side, having a separate, verified, reliable BLE stack in the form of a SoftDevice allows firmware engineers to focus more energy on their application-level code. They can deal with a smaller API and higher-level concepts such as GAP (Chapter 3) and GATT (Chapter 4), leaving the lowest-level details to the SoftDevice (security implementation, message validation, etc.).
The SoftDevice also allows firmware developers to avoid dealing with radio configuration themselves, which can be a significant part of the firmware development process in most RF products. Turning these details into a black box protects firmware engineers from making low-level mistakes and can significantly simplify the product validation process, because the low-level BLE code is guaranteed to function according to the Bluetooth Core Specification.
Another advantage of the SoftDevice approach is it allows one hardware design to support multiple radio protocols or use cases, including the ability to design a custom protocol, which might lower product costs in companies with multiple similar in-house products based on a single PCB design.
Finally, the SoftDevice’s architecture is nonintrusive to application developers. Because it runs independently and the application does not need to link against any set of libraries, both SD and application updates can be performed separately with no dependencies, much in the way one can update a Linux kernel or user-space libraries independently without worrying about the other side being affected by the update.
On the down side, the SoftDevice requires system resources that will not be available for your own application’s use. The S110 SoftDevice allocates the bottom 80 KB of flash and 8 KB of SRAM, leaving you with 176 KB flash and 8 KB SRAM for your own application (assuming the 256 KB version of the nRF51822 is being used).
The SoftDevice design also introduces latency and architectural limitations, as higher-level code needs to make calls down to the SoftDevice from your higher-level code, which happens through sofware interrupts on the ARM core.
As with any big engineering task, the numerous benefits the SoftDevice brings to the table require some sacrifices, mainly around timing and hard real-time requirements.
Working with the nRF51822-EK
If you are interested in evaluating the nRF51822, the best platform to begin with is Nordic’s nRF51822-EK. As shown in Figure 5-1, this evaluation kit includes two development boards: the PCA10001 (shown on the left) and the PCA10000 (shown on the right).
Figure 5-1. Nordic Semiconductor’s nRF51822-EK
The PCA10000 is a small USB dongle used primarily for debugging, either by simulating a central device via Nordic’s Master Control Panel or as a sniffer to push data out to Wireshark (both of which are discussed in Chapter 7). But it’s also a full-featured development board on its own, with an integrated Segger J-Link that allows you to program and debug the firmware using a variety of development tools.
The larger PCA10001 is the main development board in the kit. It breaks out all of the pins available on the nRF51822, enabling you to connect I2C or SPI sensors or peripherals, talk to other devices over UART, etc. This board also includes a J-Link on board to program and debug the MCU, as well as some additional circuitry to measure power consumption and make prototyping and debugging easier. The UART ouput is optionally directed out over USB, for example, so you can easily visualize debug messages or send simple commands back to the MCU. It also features a CR2032 battery holder to allow the board to be powered by a small battery.
Examples and Toolchains
Nordic provides numerous examples (after registering your kit, as discussed in the note following this paragraph) based on this development kit, making it an easy choice if you just want to get started with something you know will work. Most of the demo code uses Keil’s uVision (with the IAR toolchain as a second option), which is freely available from ARM for noncommercial use on projects smaller than 32 KB (which should actually cover a broad range of projects, because the SoftDevice is not included in the 32 KB limit, only the application code).
You will need to create a MyPages account on Nordic Semiconductor’s website and register the serial number for your nRF51822-EK before you can access the latest demo code and development tools for this chipset.
Some support materials and sample projects are also available for GNU-based tools, although GNU (and Eclipse) support is not as extensive as the support for Keil uVision. However, it is worth noting that developing full applications on GNU/Linux and Mac OS X is currently possible without having to resort to Windows.
To provide an open source option, we’ve also included a basic code base in the GitHub repository for this book. This code is based on the freely available GNU toolchain, including makefiles, startup code, and some basic tools to program the flash using the onboard J-Link debuggers.
CC2541DK-MINI (Texas Instruments)
Another company with a long history in the low-power RF field, Texas Instruments has designed a number of BLE system-on-chips (SoCs) targetting the peripheral market, and was the first to market with a peripheral BLE solution.
The CC2541 combines the following features:
§ 8051 core with a 2.4 GHz radio
§ 128 or 256 KB user-programmable flash memory
§ 8 KB SRAM
One of the biggest advantages TI has over some of its rivals is that its BLE stack is feature complete, essentially covering the entire 4.0 version of the Bluetooth Core Specification. Some vendors have chosen not to implement certain infrequently used optional features, whereas TI has made an intentional effort to reach a bit further in its functionality coverage.
The CC2541 is also pin-compatible with the CC2540, which adds USB support to the SoC. This potentially extends the lifespan of any design efforts around this chip family with minimal additional design effort, since you can easily move your designs over to peripherals that are connected to desktop or laptop PCs via USB connectivity.
TI takes design and testing seriously, and its RF chip families have a long design lineage. It makes reliable chips using well-designed radios and provides significant design resources around those chips, for both hardware designers and firmware engineers. This can be an important consideration for small companies without a lot of in-house RF or embedded firmware design expertise.
One big weakness of the CC2541 is the relatively dated 8051 core driving its SoC, which not only requires an expensive commercial compiler and IDE to use (IAR Embedded Workbench), but also feels quite long in the tooth compared to more modern ARM Cortex-M cores making their way into many other SoCs. This will likely change in the near future, as SoC vendors feel greater pressure to move to newer cores, and TI is no doubt well aware of the trend. It will be interesting to see how the company responds moving forward.
Among the many development kits available for TI’s CC254x family, the low-cost CC2541DK-MINI (Figure 5-2) platform should enable peripheral designers to thoroughly evaluate the development platform and SoC.
This kit includes all of the hardware you’ll need to start working with the CC2541, including a hardware debugger, a USB dongle that can act as a BLE master device on your PC, and a key fob development board that can run your custom BLE code.
One attractive element of this development kit is that it closely resembles a real product, with an injection-molded enclosure and two large, physical buttons that provide real feedback during the initial development and debugging process. It’s easy to overlook these kinds of details in the early stages of product development, but they can help give an idea of the real-world performance of a BLE device, even if some specifics (such as operating range) will of course vary from one device design to another.
Figure 5-2. Texas Instruments’ CC2541MINI-DK development kit
Simply holding a low-power device in your hand will often attentuate the signal, providing a very different experience than a raw PCB sitting unobstructed on a desk a few feet away from your laptop. It’s also easier to get a battery-powered device in an enclosure off the work bench and do something with it in the real world, such as attaching it to something or someone else. It’s a small detail, but it can save you both time and potential surprises later if you didn’t get your development kit off your desk early on in the design process.
For further information on this development kit, including ordering details, see the CC2541 product page on the Texas Instruments website.
Other Hardware Platforms and Modules
If you’d rather not build your own RF devices and circuit boards from scratch, modules provide an alternative approach. One of the key advantages of modules is that they typically come precertified as intentional emitters by the various regulatory bodies, such as the FCC or CE/ETSI, and are likely to pass any test programs set up by the various protocol bodies, such as the Bluetooth SIG. FCC or CE certification can easily cost $10,000 per product, making modules an attractive option for products produced in relatively low volume.
Another advantage of using a module is that the RF design is done for you, whereas custom RF hardware design requires specialized knowledge, tools, and testing. Properly designing an antenna or RF front end on a product is a nontrivial task, and poor design can significantly affect the operating range and efficiency of your products. Module makers generally solve this problem for you by providing a properly designed and tuned RF front end and antenna or a common connector that allows you to easily add an external antenna to your product without having to worry about impedance matching on the transmission line (the metal trace that transmits energy to and from the radio).
As another advantage, some modules (e.g., the Bluegiga modules or Laird modules discussed later in this section) come with high-level development scripting languages that can significantly reduce development time and avoid some of the difficulties of working with low-level programming enviroments such as Keil’s uVision for Nordic’s nRF51822-EK (nRF51822-EK (Nordic Semiconductors)) or IAR for Texas Instruments’ CC2541MINI-DK (CC2541DK-MINI (Texas Instruments)). They only require a text editor for code development.
Of course, the benefits of using modules come at a cost. The per-unit price of modules is significantly higher than designing your own hardware using individual integrated circuits (such as the nRF51822 or CC2541). Module makers spread out the design, verification, and certification costs across multiple products and allow low-volume products to hit a price point they wouldn’t be able to on their own, but at some point (probably upward of 10,000 units), designing and certifying your own hardware might be more cost effective.
The rest of this section describes three BLE modules available at the time of this writing.
Laird’s BL600 Module
Laird’s BL600 module is based on Nordic Semiconductor’s nRF51822 (nRF51822-EK (Nordic Semiconductors)). In addition to all of the raw functionality included in the nR51822, these modules add an event-driven smartBASIC programming language that allows you to easily create basic applications without having to learn or invest in expensive commercial IDEs and compilers, or having to program in low-level languages like C or C++.
You’re free to program the modules directly using standard C code and Nordic’s SDK and toolkit for the nRF51822, but the smartBASIC option might be useful for simple use cases in which you just need to add a wireless link to your product with a minimum of development effort and without having to learn a new stack and technology in depth.
This module has regulatory certifications for CE/ETSI (Europe), FCC, Industry Canada, Japan, and the NCC (Taiwan), as well as Bluetooth SIG Qualification, and is also available for purchase from many major component resellers online.
Bluegiga’s BLE112/BLE113 Modules
Bluegiga’s BLE112 and BLE113 modules are based on the CC2540/CC2541 from Texas Instruments (CC2541DK-MINI (Texas Instruments)). They include support for BGScript, which allows you to program certain types of applications using simple XML files. Bluegiga also provides a C API to work with these modules using an external MCU, talking to the modules over UART.
The main difference between the BLE112 and the BLE113 is that the newer BLE113 module has slightly lower power consumption and adds a hardware I2C port, which can be used to talk to a wide variety of low-cost sensors (temperature sensors, accelerometers, gyroscopes, pressure sensors, etc.)
These modules have the regulatory certifications for CE/ETSI (Europe), FCC, Industry Canada, Japan, and South Korea and are available for purchase from most major component resellers (Digikey, Mouser, Farnell, etc.).
The RFDuino is a small BLE module that allows you to use the popular Arduino IDE and development platform to create BLE devices. If you’re already familiar with Arduino, the RFDuino is an excellent entry point to experiment with BLE, because it can significantly lower the learning curve involved in getting an initial prototype up and running.
These modules have the regulatory certifications for CE/ETSI (Europe), FCC, and Industry Canada and are available from several component resellers, including Mouser and Arrow.