BLE400 board and development for nRF51822
For development under the nRF51822 microcontroller, there are several kits from Nordic Semiconductor, all of them are quite expensive, but they provide the ability to conveniently work without fuss with programmers. At the same time, Chinese manufacturers can find boards that facilitate the debugging of controllers for ridiculous money. This article is about working with a clone of a Waveshare board sold under the name BLE400 .
The board is intended for use with NRF51822 modules, which are a soldered chip with an antenna and a pair of quartz resonators. The cost of the kit from the board and module is about $ 20.
The BLE400 contains onboard a USB port and a USB-UART converter based on the CP2102 chip with RX, TX, CTS and RTS signals output. At the circuit level, it is partially compatible with the PCA10001, a Nordic debugging board, a pair of LEDs and two buttons connected to the same ports, for those who like to blink an LED, this will make life a little easier. Unfortunately, the board does not know how to play the role of the nRF51822 programmer, although there is firmware available to work with an Arduino-type bootloader. I’ll briefly list what exactly is built into the board, in part it will be a translation of the documentation from here .
Initially, the code for working with nRF Toolbox for BLE from Nordic Semiconductor was flashed into the module , this is enough to test its functionality. We connect the board to the PC, install the drivers for CP2102 and connect to the board using the terminal. I used PuTTY, port parameters: speed 38400 date bit 8, Stop bit one, software flow control.
We are connected, in the terminal we drive in the English character Y or y, we get the Start ... command in response - the controller works.
Now it is available in the list of BLE compatible devices on the phone with the name Nordic_UART. After installing the Android application, you can play around with the transmission of characters through the virtual Bluetooth terminal and test the emulation of UART.
We pass to programming. We still need a programmer, the original from Segger will be a little expensive, but thanks to car enthusiasts, J-link ARM v8 clones are enough on the market, they cost about $ 15 and more than enough for our purposes. We assume that drivers for the programmer (for example, J-Link Software v4.52b +) are already installed. We connect to the board with a standard JTAG cable from the programmer or four wires, just connect VTref, GND, SWDIO and SWCLK.
To test the connection, run JLink.exe and get information about the installed chip
We will need the following software
To obtain the Lite version of Keil MDK-ARM, registration is required, the rest is available for download as follows. nRFgo Studio version 1.21.2 did not start for me under Windows 10, but the younger version 1.15.1 works. The latest version of the SDK with support for the pca10001 board is version 6, download the link . After installing the SDK, a directory
You can program the board not only through the J-Link Commander console, but also through nRFgo Studio, through it we can clear the chip or fill in SoftDevice for working with Bluetooth. This is done from the nRF51 Programming menu. The chip is already flooded with the core of the BLE stack. You can clear it through the menu item Erase all.
The next task is to flash the LEDs carefully soldered on the board. As mentioned earlier, the LEDs and buttons are compatible with the Nordic pca10001 board, so we use the example from there, open the blinky.uvproj
We assemble the project by pressing F7 and flash through the menu Flash-> Download. It didn’t flash by default due to the default JTAG fill speed of 2000 kHz. You can fix it from the menu Option for target -> Debug -> Setting. After replacing with 100 kHz everything worked successfully. LEDs LED0 and LED1 successfully blink, the microcontroller is working. If you still cannot download, you can try to flash HEX from the folder
LEDs are great, but we still need Bluetooth, an example for work is in the folder
Initially, the header files for version 7.0.0 come with the SDK, but this kernel version did not start for me. Theoretically, any version of the stack should work, versions v6, v7, v8 are available for download. With examples from the SDK, the seventh and eighth versions of the stack did not work for me, I stopped at 6.2.1.
Download the kernel , unpack it into a folder convenient for you, for example, Cores
SoftDevice needs to be flashed, for this we use nRFgo Studio, select nRF51 Programming from the Device Manager menu and make sure that the programmer does not fall off. In the Program SoftDevice tab, select the kernel file
Click the Program button. The device’s memory card now looks like this:
8kb less RAM, and the kernel took up the first 80 kilobytes of read-only memory. Change Target to the target with s110 stack, select nrf51822_xxaa_s110 (256K) from the menu
To build an example with a blinking LED with SoftCore installed, you need to enter corrections into the memory card, this is done from the Options for Target - Target menu. The base address changes to
Since when filling in the sketch we should not overwrite the kernel, we change the programmer settings. This is done from the Options for Target - Debug menu, Setting button.
We assemble the project and fill it into the controller, if the kernel is installed correctly, we will get the same blinking LEDs. It's time to upload firmware simulating iBeacon, open the project from the folder
If everything went successfully, LED0 will be lit, this is an indicator that packets are being sent. Install the application that can see iBeacon on an Android or iOS device, I downloaded
Beacon Scanner . The UUID of the device is the same as the constant APP_BEACON_UUID in the source code, so this is our beacon.
In principle, this information is enough for a quick and very inexpensive start to work with BLE. On the downside, it supports outdated Keil 4 and unstable programmer operation at frequencies of 100 kHz and higher. If the development environment throws a download error, reduce the access speed to 50 kHz or even less. Sometimes the programmer falls off and you can return it to life only by running JLink.exe, perhaps this is due to the fact that it is a clone of the original.
The board is intended for use with NRF51822 modules, which are a soldered chip with an antenna and a pair of quartz resonators. The cost of the kit from the board and module is about $ 20.
The BLE400 contains onboard a USB port and a USB-UART converter based on the CP2102 chip with RX, TX, CTS and RTS signals output. At the circuit level, it is partially compatible with the PCA10001, a Nordic debugging board, a pair of LEDs and two buttons connected to the same ports, for those who like to blink an LED, this will make life a little easier. Unfortunately, the board does not know how to play the role of the nRF51822 programmer, although there is firmware available to work with an Arduino-type bootloader. I’ll briefly list what exactly is built into the board, in part it will be a translation of the documentation from here .
- The seat is for the NRF51822 module, there are no keys, the module can be inserted incorrectly, but then it will close the battery and the antenna will be vice versa
- Duplicates the pins of the NRF51822 module, convenient for prototyping
- The I2C interface, brought up for ease of connection, duplicates the corresponding signals from the SDA comb - P0.00 SCL - P0.01 SMBA - P0.02 and power, ready-made modules from Waveshare can be used
- SPI interface, signals MISO - P0.23 MOSI - P0.24 SCK - P0.25 NSS - P0.30
- Power, when connected via USB, you can use 5 volt power, only 3.3 will be available from the battery and the programmer. The power supply is made on RT9193 with a maximum current of 300mA, the module itself consumes a maximum of 2mA and is ready to give a maximum of 3 pins of 5 mA or 1 pin with a current of 15mA to the load. Total 250 mA to the periphery in stock
- Mini-USB jack for connecting power or connecting to a PC. 5 volt port is directly connected to the power comb
- Simplified SWD programming interface. Powered 3.3v, SWDIO and SWCLK
- Duplicated UART, it is also connected to CP2102 and is available for monitoring on a PC via a virtual COM port. RX - P0.05 TX - P0.06 CTS - P0.07 RTS - P0.12
- Battery size CR1225, useful for stand-alone testing
- A set of LEDs connected to P0.18 P0.19 P0.20 P0.21 P0.22. Lit when a logical unit is lit. Here you can see the activity of the signals RX, TX and SPD
- Two buttons connected to ports P0.16 and P0.17. When pressed, gives a logical zero
- Reset button. Resets CP2102 and NRF51822 by zeroing the SWDIO signal
- Virtual COM port controller on CP2102, DTR and DSR not soldered
- Jumpers for disconnecting the UART interface from the CP2102
- Jumpers for disabling LEDs and buttons
Initially, the code for working with nRF Toolbox for BLE from Nordic Semiconductor was flashed into the module , this is enough to test its functionality. We connect the board to the PC, install the drivers for CP2102 and connect to the board using the terminal. I used PuTTY, port parameters: speed 38400 date bit 8, Stop bit one, software flow control.
We are connected, in the terminal we drive in the English character Y or y, we get the Start ... command in response - the controller works.
Now it is available in the list of BLE compatible devices on the phone with the name Nordic_UART. After installing the Android application, you can play around with the transmission of characters through the virtual Bluetooth terminal and test the emulation of UART.
We pass to programming. We still need a programmer, the original from Segger will be a little expensive, but thanks to car enthusiasts, J-link ARM v8 clones are enough on the market, they cost about $ 15 and more than enough for our purposes. We assume that drivers for the programmer (for example, J-Link Software v4.52b +) are already installed. We connect to the board with a standard JTAG cable from the programmer or four wires, just connect VTref, GND, SWDIO and SWCLK.
To test the connection, run JLink.exe and get information about the installed chip
SEGGER J-Link Commander V4.74b ('?' for help)
Compiled Aug 19 2013 23:26:57
DLL version V4.74b, compiled Aug 19 2013 23:26:44
Firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46
Hardware: V8.00
S/N: 20091135
Feature(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTarget = 3.293V
Info: Found SWD-DP with ID 0x0BB11477
Info: FPUnit: 4 code (BP) slots and 0 literal slots
Info: Found Cortex-M0 r0p0, Little endian.
Found 1 JTAG device, Total IRLen = 4:
Cortex-M0 identified.
JTAG speed: 100 kHz
We will need the following software
To obtain the Lite version of Keil MDK-ARM, registration is required, the rest is available for download as follows. nRFgo Studio version 1.21.2 did not start for me under Windows 10, but the younger version 1.15.1 works. The latest version of the SDK with support for the pca10001 board is version 6, download the link . After installing the SDK, a directory
\ARM\Device\Nordic\nrf51822
containing all the necessary files will appear in the folder where the Keil environment is installed . The examples are designed for using Keil version 4, the project file has the uvproj extension, unlike Keil 5 where the uvprojx extension. Actually, we use Keil 4 so as not to get confused in the configuration files and example compatibility.You can program the board not only through the J-Link Commander console, but also through nRFgo Studio, through it we can clear the chip or fill in SoftDevice for working with Bluetooth. This is done from the nRF51 Programming menu. The chip is already flooded with the core of the BLE stack. You can clear it through the menu item Erase all.
The next task is to flash the LEDs carefully soldered on the board. As mentioned earlier, the LEDs and buttons are compatible with the Nordic pca10001 board, so we use the example from there, open the blinky.uvproj
\ARM\Device\Nordic\nrf51822\Board\pca10001\blinky_example\arm\
project file in the folder with Keil4. We assemble the project by pressing F7 and flash through the menu Flash-> Download. It didn’t flash by default due to the default JTAG fill speed of 2000 kHz. You can fix it from the menu Option for target -> Debug -> Setting. After replacing with 100 kHz everything worked successfully. LEDs LED0 and LED1 successfully blink, the microcontroller is working. If you still cannot download, you can try to flash HEX from the folder
_build blinky_arm.hex
using nRFgo Studio or from the console of the J-Link programmer. But first, you should make sure that the J-Link programmer is selected in the Keil settings.LEDs are great, but we still need Bluetooth, an example for work is in the folder
\ARM\Device\Nordic\nrf51822\Board\pca10001\s110\ble_app_beacon
. This is the implementation of iBeacon, for us it is interesting to work with the software BLE stack from Nordic. The example is designed for the s110 stack version, the simplest in terms of capabilities, but this is enough to demonstrate the functionality. The kernel needs to be downloaded separately and there are many versions of it, while the version of the headers should correlate with the version of the kernel. You can download the kernel from the link in the SoftDevices section. Initially, the header files for version 7.0.0 come with the SDK, but this kernel version did not start for me. Theoretically, any version of the stack should work, versions v6, v7, v8 are available for download. With examples from the SDK, the seventh and eighth versions of the stack did not work for me, I stopped at 6.2.1.
Download the kernel , unpack it into a folder convenient for you, for example, Cores
ARM\Device\Nordic\nrf51822\Cores\6.2.1
. We clean the existing folder \ARM\Device\Nordic\nrf51822\Include\s110
and copy the header files from the include folder of the unpacked kernel into it. SoftDevice needs to be flashed, for this we use nRFgo Studio, select nRF51 Programming from the Device Manager menu and make sure that the programmer does not fall off. In the Program SoftDevice tab, select the kernel file
\ARM\Device\Nordic\nrf51822\Cores\6.2.1\s110_nrf51822_6.2.1_softdevice.hex
. If the file of the correct format is indicated below the occupied capacity, for this version of SoftDevice is equal to 80kb.Click the Program button. The device’s memory card now looks like this:
8kb less RAM, and the kernel took up the first 80 kilobytes of read-only memory. Change Target to the target with s110 stack, select nrf51822_xxaa_s110 (256K) from the menu
To build an example with a blinking LED with SoftCore installed, you need to enter corrections into the memory card, this is done from the Options for Target - Target menu. The base address changes to
CODE_R1_BASE = 0x00014000
, and free memory starts at 0x20002000.Since when filling in the sketch we should not overwrite the kernel, we change the programmer settings. This is done from the Options for Target - Debug menu, Setting button.
We assemble the project and fill it into the controller, if the kernel is installed correctly, we will get the same blinking LEDs. It's time to upload firmware simulating iBeacon, open the project from the folder
\ARM\Device\Nordic\nrf51822\Board\pca10001\s110\ble_app_beacon
. We change the memory card by analogy with the flashing LED, collect and fill it into the device. If everything went successfully, LED0 will be lit, this is an indicator that packets are being sent. Install the application that can see iBeacon on an Android or iOS device, I downloaded
Beacon Scanner . The UUID of the device is the same as the constant APP_BEACON_UUID in the source code, so this is our beacon.
In principle, this information is enough for a quick and very inexpensive start to work with BLE. On the downside, it supports outdated Keil 4 and unstable programmer operation at frequencies of 100 kHz and higher. If the development environment throws a download error, reduce the access speed to 50 kHz or even less. Sometimes the programmer falls off and you can return it to life only by running JLink.exe, perhaps this is due to the fact that it is a clone of the original.