An absolute beginners guide to nRF52840
By: Teja Chintalapati
Tags: Nordic Semiconductor, Technology, Tutorial, Nrf52840, Getting Started

Hello world!

Flashing pre-compiled HEX files

Take an nRF52840 Development kit and connect micro-USB cable to J2(Left side) connector

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

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”

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

Load firmware to nRF52840 board

Once loaded click on “Continue Execution”(Play) button again to run your application on development board

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\

Navigate to \SDK_LOCATION\examples\ Step 2: Create a new folder and name it. The location will be: \SDK_LOCATION\examples\ yourProjectFolderName

Create a new folder and name it. The location will be: \SDK_LOCATION\examples\ Step 3: Go to any project in \SDK_LOCATION\examples\peripheral\ and choose any project you like

Go to any project in \SDK_LOCATION\examples\peripheral\ and choose any project you like Step 4: Copy the example project

Copy the example project Step 5: Go to \SDK_LOCATION\examples\yourProjectFolderName and paste the example project you copied in the last step

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

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:

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

Other Interesting Stuff