Nordic Radio's NRF52832 is a nice little chip -- It has a Cortex M4 running at 64 MHz, a 2.4 GHz RF transceiver, 512 kb of flash, a 12 bit 200 ksps ADC, 5x 32 bit timers, a flexible peripheral interconnect system with DMA, and lots of other bells and whistles.

In particular, the chip performs very well for its cost on tests measuring the speed of information transfer in and out of the CPU and over the RF channel.

Programming the NRF52

Programming involves two steps: 1) compiling code, and 2) flashing the code to the chip.

Thanks to the folks at Adafruit, you can use the Arduino IDE to perform both steps. Instruction on installing the appropriate libraries can be found here.

To build the toolchain for compilation manually, you can follow the instructions on this page (starting at heading "GNU ARM Compiler").

The steps for flashing your code depends on what board and programmer you have.

Adafruit Feather NRF52 Board

This is a great board; I would highly recommend it for NRF52 projects.

This board comes flashed with a Serial DFU bootloader and it has an onboard USB-to-Serial converter. This allows you to program it simply with a USB cable.

Custom boards

If application requirements don't allow you to use the Feather board from Adafruit, you can also build custom boards around the available NRF52 modules.

The Adafruit board uses the Raytac MDBT42Q, available from Digikey (PN 1597-1434-ND) for $14.

Fanstel also makes a variety of modules with the NRF52832 as well as the NRF52840 (with USB 2.0 support). The BC-832 is a very small module (7.8mm x 8.8mm) available for $7.60 in quantity 10. The BT-832 is slightly larger, but comes in a variety ranges and sells for just $5 in quantity 10.

Below is a custom board using the Fanstel BC832 module. It is just 23mm x 18mm, and is designed to use a serial DFU bootloader for programming with a standard FTDI cable.

BC832 Traces BC832 Interior

Making a custom board requires programming via Serial Wire Debug (SWD), at least for the bootloader. Two methods for this are described below.

Programming with Segger J-Link

The Segger J-Link is a very helpful tool, but it's quite expensive. With it, we can use Nordic's command line utilities, including nrfjprog. I wrote a shell script with three commands to erase, flash the adafruit bootloader, and then start the chip running.

nrfjprog -f nrf52 --eraseall
nrfjprog -f nrf52 --program feather52_bootloader_v050_s132_v201.hex
nrfjprog -f nrf52 --run

The J-Link requires a wire to ensure the target has power. In the image above, red is target power (3.3V), black is ground, green is SWDCLK, and blue is SWDIO.

Programming with OpenOCD and Raspberry Pi

You don't have to spend hundreds on a J-Link (even though it is very nice). Using OpenOCD, we can make a Raspberry Pi bit-bang the programming protocols.

This page is a very helpful introduction to programming using OpenOCD and the BCM2835.

Support for the NRF52 is not in the stable release of OpenOCD as of V 0.10, but you can patch it following the instructions on this page. They worked for me, with the small addition that I needed to eliminate two duplicate variable definitions that broke my build.

The openocd.cfg will also be different for the NRF52 than the linked tutorial. Here is mine for flashing a binary of the Adafruit bootloader:

transport select swd
source [find target/nrf52.cfg]
bcm2835gpio_swd_nums 25 24
bcm2835gpio_trst_num 7
bcm2835gpio_srst_num 18
reset halt
nrf52 mass_erase 0
program feather52_bootloader_v050_s132_v201.hex verify