An absolute beginners guide to nRF52840

Teja Chintalapati
6 min readSep 17, 2019

Background

While binging on YouTube, I came across this great chip — nRF52840 from Nordic Semiconductor. After seeing the product launch video on YouTube, I knew I had to buy the development boards and check them out.

nRF52840 offers some key advantages over the competition. Here are some of the advantages nRF52840 offers:

  1. Pre-certified and readily available modules from several vendors, including Raytac at a competitive price — This will considerably cut down development and manufacturing costs. Also, certifying your end product will be easy as the modules are already certified. Check this link to see all the certifications Raytac’s module already passed. Using the modules reduces your BOM and you just have to deal with one supplier as opposed to multiple suppliers (if you design your own hardware) during production. Also your PCB design will be significantly simpler as opposed to making a 4–6 layer board and tune the impedance
  2. nRF52840 comes with in-built support for NFC. This can be a very good feature to have
  3. Lastly, Nordic’s development kits are compatible with Arduino’s pin layout. This means that we can readily use a ton of cheap and readily available Arduino shields and sensors
A photo showing one of the many nRF52840 Modules available in the market.
One of many nRF52840 modules available in the market. This module measures 10.5mmx15.5mmx2.0mm. A 2.54mm male header for scale.

While I was getting started with nRF52840, I found it to be a bit difficult to find information and to get started. In this story, I collated all the information into a single story that serves as a reference for you. I believe that this will definitely help save a lot of your time. As I find more information, I shall keep updating this story.

What do you need?

  1. An nRF52840 Development Kit and a micro-usb cable
  2. A computer and
  3. A ton of patience and coffee

Where to start?

  1. If you haven’t setup your development environment already, I recommend you to use Segger Embedded Studio(SES) for developing applications using nRF52840. Follow this video series from Nordic and you will be good to go. IAR definitely has an edge over SES but SES is free. Keil while being a good alternative has a code limit beyond which you have to purchase a license. Also, you may not use Keil if you’re building a commercial product
  2. Nordic’s Infocenter has all the documentation and guides to develop your application. Everything is very well documented. Take time and understand the layout of Infocenter for you will spend a lot of time here
  3. Nordic’s Devzone offers some tutorials and also has a good blog. Should you get stuck in your development, you can seek support at Devzone

What to download?

  1. Segger Embedded Studio
  2. nRF5 SDK
  3. Java and any other dependencies that Segger Embedded Studio may need to run

Hello world!

Flashing pre-compiled HEX files

  • Take an nRF52840 Development kit and connect micro-USB cable to J2(Left side) connector
A photo showing an nRF52840 Development Kit.
An nRF52840 Development Board
  • If you’re using Windows, a new drive, JLINK, will be mounted. You can then drag and drop pre-compiled HEX files from examples to flash the development board. For example, you can load Blinky app(LED Blinking project) by dragging and dropping blinky_pca10056.hex file from: \SDK_LOCATION\examples\peripheral\blinky\hex\blinky_pca10056.hex to JLINK drive that’s mounted. This will load the blinky app on your development board
  • If everything goes well, you should see LEDS[1:4] blinking in a sequence. Congratulations!

Importing projects to Segger Embedded Studio

Nordic provides us with a lot of example projects that helps you get started with building your custom application(s). You may find the examples at: \SDK_INSTALL_LOCATION\examples\ folder where SDK_LOCATION refers to the file path where SDK is at

Let’s now import a GPIO interrupt example. This example project controls the state of LED according to BUTTON1 state. You can find documentation about this project here

  • Go to \SDK_LOCATION\examples\peripheral\pin_change_int\pca10056\ses\ and open pin_change_int_pca10056.emProject
  • After SES loads, right click on project title and click on “Rebuild
A photo showing Segger Embedded Studio layout to rebuild the project.
Rebuild project
  • If there are no errors, it’s now time to flash the board with this application
  • Open main.c if it’s not open already and click on “Start Execution”(Play) button
A photo showing position of a button, when clicked, starts loading firmware to nRF52840 development kit.
Load firmware to nRF52840 board
  • Once loaded click on “Continue Execution”(Play) button again to run your application on development board
A photo showing button layout on Segger Embedded Studio to run the firmware.
Run your application
  • Once running, press BUTTON1 on development kit and see the state change on LED1
  • Congratulations on successfully running your first project! You now know that you’ve setup everything correctly and are able to communicate with the development board.

In the next step, let’s see how to create a new project and customise it.

Creating a new project

Creating a new project wizard for nRF chips has a lot of potential to improve. Creating a new project for TI’s controllers on Code Composer Studio(CCS) has always been a breeze. In nRF case, creating a new project from scratch can be a daunting exercise. There’s no easy way to include all the drivers and other files and therefore I recommend you to use a template, as explained here, here and here.

As recommended, I created a new folder in “examples” folder and keep all my projects there. Let’s now start creating a new project that you can customise later.

  • Step 1: Navigate to \SDK_LOCATION\examples\
  • Step 2: Create a new folder and name it. The location will be: \SDK_LOCATION\examples\yourProjectFolderName
  • Step 3: Go to any project in \SDK_LOCATION\examples\peripheral\ and choose any project you like
  • Step 4: Copy the example project
  • Step 5: Go to \SDK_LOCATION\examples\yourProjectFolderName and paste the example project you copied in the last step
  • Step 6: Follow the steps listed in the last section to open the project and flash it on your development board
  • Step 7: Go to Infocentre, read the documentation and make changes to the original code and customise as you like.

Congratulations on your new project!

Recap

In this story, we learnt the following:

  1. Advantages nRF52840 brings to the table
  2. Where to start if you are new to the nRF5 development, where to seek for help if you’re stuck and what to download
  3. Flashing the pre-compiled HEX files on the development board by dragging and dropping them to mounted JLINK drive on your computer
  4. Open a sample project, flash it and run it on the development board
  5. How to use example project(s) as a starting point to create new projects

Other Interesting Stuff

  1. Check out Electronut Labs. Most of their products as of writing this story are powered by nRF52840. They make unique products and sell them worldwide. Also checkout their blog for inspiration.
  2. Sparkfun has a good tutorial on nRF52840 here
  3. makerdiary makes some very interesting hardware with nRF52840
  4. If you’re interested in developing BLE Applications, check out Novelbits. They have a great tutorial on getting started with BLE development

Finally, thank you for taking time reading this elaborate story. I hope you had fun reading this as mush as I did writing this story.

Until next time, happy hacking.

--

--

Teja Chintalapati

Technologist with a passion for building consumer and industrial electronics and the native apps that work with them.