Table of Contents
Overview on Nordic IoT Chips
Nordic Semiconductor is a semiconductor MNC, which designs & develops a wide range of SoCs supporting IoT protocols. These SoC\’s have all functionalities of Microcontroller(MCU) based on ARM cortex Processors, plus they embed 2.4ghz RF transceivers into the chips using RF-CMOS technology for making IoT chips.
NRF52 and NRF51 series of SoC\’s are widely accepted across the industries where there is a need for Low Power/Ultra Low Power consumption IoT solutions. Nordic Semiconductor NRF5xxx SoC is ideal for Ultralow power and cost-effective short-range wireless solutions. Typical applications for NRF5xxx SoC are:
- IoT(Internet of Things) devices
- Wearables
- Smart Home
- Wireless Mobile Phone Accessories
- PC Peripherals
- Beacons
- Bluetooth-enabled consumers
NRF51 & NRF52 Series have all hardware support of MCU peripherals like ADC, SPI, I2C, UART, GPIO, TIMERS, etc, and 2.4ghz RF transceivers for hardware support of IoT protocols into the chip. Thus NRF5xxx series of SoC can be used for Embedded devices applications(Using MCU peripherals like UART, SPI, I2C, TIMERS, ADC, RTC, USB, etc.)and IoT applications( using protocols like BLE, ZigBee, Thread, ANT, etc.) simultaneously.
NRF5x Series supports the following short-range IoT protocols:
- BLE
- THREAD
- ZigBee
- ANT
- Near Field Communication
- NRF Proprietary IoT protocols: ESBP & Gazell.
Nordic Semiconductor also provides a full suite of IoT stacks to support of above IoT protocols. Nordic Semiconductor has named them Softdevices. To get to know about IoT protocols supported by Nordic chips you can refer to this.
Nordic Semiconductor provides a wide range of development hardware from development kits to USB dongles for fast prototyping and hobbyists to play with NRF5x IoT Soc.
How to get started??
We will be using Nordic NRF52840 – DK, which is the official development board for the NRF52840 SoC. Now when I first got the NF52840 DK, it is very different from Arduino, STM, ESP boards. It has lots and lots of chips on it and quite fascinating to explore what all hardware is on it for what purposes.
nRF52840-Development Kit
At the same time, it is very confusing for me also on how to start with these IoT chips as they have so many features and functionalities on them. From MCU peripherals to IoT stacks, Crypto engines, Power management, analog features, and many more.
nRF52 and nRF51 Chips
So what I decided at first will start from exploring MCU peripherals, understanding peripheral driver header, and source files: HAL & LL. Subsequently will get to know about the Development environment and SDK of NRF chips. Starting from basics at first and then will move to IoT protocols, in that also we will first start from BLE and then to other IoT protocols. Those who don\’t want to explore NRF52840 MCU peripherals can directly start from the BLE part of NRF5x chips.
At first, we will make some application code using NRF5x MCU peripherals like GPIO, UART, SPI, I2C, TIMERS and etc. Will understand the HAL APIs provided by Nordic SDK for these peripherals. Will then interface different sensors and modules for making embedded devices. Then will understand the supported IoT protocols architecture and stacks.
Now to get started with any MCU or SoC the first couple of things we have to understand are:
- Its Development Software: Software Development KIT(SDK), Integrated Development Environment (IDE), Debuggers, Environment setup for cross-compilation from our laptop/desktop to the designated MCU processor.
- Then we have to gather & understand the development board of the corresponding semiconductor chip. As development boards are the fastest and easiest way to get started with semiconductor chips. We will be using NRF52840- Development Board in this series and all the blogs and videos will be on it only.
Development Software for Nordic SoC\’s
Toolchain setup for Nordic SoC\’s
- At first, we need an IDE. IDE provides a complete solution and one-stop environment for firmware development on microcontrollers. So Nordic Semiconductor provides 2 IDE for the development: Seger Embedded Studio and Arm® Keil µVision. The one which is recommended and preferred to use is Seger Embedded Studio (SES). So, in this tutorial series, we are going to use Seger Embedded Studio (SES). SES is a professional IDE that is highly recommended and used in the industry. SES is free to use for Nordic chips and its installation is pretty easy, can be downloaded from this link. Seger Embedded Studio
- Nordic chips are programmed and debugged using J-Links. Nordic NRF52840-DK has an onboard Jlink debugger and programmer. So we don\’t have to care much about the hardware side of the debugger, but we have to install some software packs for using the Onboard J-Link debugger. We will install the Segger J-link Software and save it along with the same directory as that of SES.
So that all that we have to set up for the toolchain of Nordic Chips, successfully installed the IDE and Debugger pack for Developing for Firmware on Nordic chips. At first, when we open the Segger Embedded Studio, it will open with a Hello world example as shown below.
Segger Embedded Studio first time open page.
How to get started with Seger Embedded Studio for NRF52840
nRF5 Series: Developing with SEGGER Embedded Studio (nordicsemi.com)
Software Development Kit for Nordic SoC\’s
Once we have set up the toolchain, we will now explore and understand the SDK provided by Nordic. SDK includes the building blocks for developing applications. This includes the framework, peripheral libraries, Source & Header files of drivers, RF stacks, example codes for various applications, bootloaders and etc. Every MCU vendor provides the SDK, which is written in C/C++ languages to get started. One will write the source code in SES IDE using SDK provided by Nordic.
Now as we navigate to the Nordic Semiconductor website under the Development Software Section, we will see there are a number of SDK packs which are listed:
- nRF 5 SDK
- nRF SDK for Mesh/Zigbee/Thread
- nRF Connect SDK
- nRF MDK
- Softdevices
Overview of Nordiac SDK\’s
At first, it is very confusing for me & can\’t figure out which SDK is for what purpose. Short overview about the above different SDK are as follows:
- nRF5SDK: provides the rich development environment for nrf5 series devices which includes programs for a broad selection of drivers, libraries, examples for peripherals, softdevices, and propitiatory radio protocols.
- nRF SDK for Mesh/Zigbee/Thread: is the implementation of applications for Thread/Zigbee/BLE Mesh protocols.
- nRF Connect SDK: contains programs for Cellular IoT, Bluetooth Low Energy, Mesh, Thread, Zigbee stacks. Range of application samples and reference implementation as well as the full suite of drivers for nordic semiconductor devices. it also supports Zephyr RTOS.
- nRF MDK: The nRF MDK provides device support in the form of register header files and startup code to get you started developing with nRF51, nRF52, nRF53, and nRF91 Series devices faster.
- Softdevices: Softdevices is a precompiled linked binary software implementing a wireless protocol developed by Nordic Semiconductor. Its API is available to applications as a high-level programming language interface.
I guess still many of you must have not got the exact clarity that which SDK is for what purpose, neither do I get at first. The ones which are important and are of concern are nRF5 SDK and NRF5 connect SDK. nRF5 SDK is older then nRF5 Connect SDK and nRF5 SDK is at maintenance state only while NRF% connect SDK is Active, receiving all future updates. Others SDK and Tools of Nordic we will explore after peripheral parts of Nordic chips.
nRF5 SDK
As at first, we are focusing on the peripheral drivers and peripheral examples. That thing is provided by nRF5 SDK. So, at first, we are going to focus on nRF5 SDK and will download the latest SDK from here.
At the time of writing this blog nRF5 SDK version number, 17.1.0 is the latest one so I have downloaded that one and kept it under the Documents folder as shown here. Documentation of nRF5 SDK 17.1.0 can be downloaded from here.
nRF5 SDK folder
We can see there are 8 folders in the nRF5 SDK v17.1.0( at the time when I have written the blog). Out of these 8 folders, modules & examples folders are of concern right now. Rest we will explore and understand as needed.
- Under the examples folder, it contains various example codes for IoT protocols and for peripherals.
nRF5 SDK example folder
We will be using a peripheral folder, which contains various application projects using the peripherals of the Nordic SoCs. Hello, World project in embedded is Blinking the LED\’s, so our first code to explore will be Blinky example.
nRF5 SDK example peripheral folder
- Under the modules folder, we will see there is a folder by the name of nrfx. It is like STM32 HAL or Arduino Core, which is being used by all the peripheral examples. nrfx folder
nrfx
nrfx is a standalone set of drivers for the peripheral present in Nordic Semiconductor SoCs. It is originated as an extract from the nRF5 SDK. The intention was to provide drivers that can be used in various environments without the necessity to integrate other parts of SDK into them. It is like STM32 HAL or Arduino Core.
For the User\’s convince, the drivers come with the MDK\’s package. This package contains definitions of registers, structure & bitfields for all supported SoC\’s as well as startup and initialization files for them.
nRF5 SDK nrfx peripheral folder
Under the nrfx folder, below-listed folders are their whose purposes are written in front of them and can also be read from the READ.md file.
- doc: Documentation files for understanding nrfx API and program.
- drivers: nRFx LL drivers (e.g: nRFx gpio_nRFx_gpio.c)
- HAL: HAL files for LL drivers (e.g: nRF_gpio.h, nRFx_gpio.c)
- helpers
- mdk: register header files & startup code for developing with nRF51/52/53/91
- SoC: SoC based files (e.g interrupts and atomic)
- templates: Templates of nrfx integration files (nrf_congig.h, log, glue files).
Now so that\’s all for the time being we need to know about the Software development kit for using the peripherals of Nordic chips. We will now open the Blinky example project which is part of nRF5 SDK at the Segger Embedded Studio and build/flash the blink led sketch into our NRF52840 SoC.
Development Hardware
nRF5x series of chips
There are 3 chips in nRF5x SoC family. nRF51 has 4 chips in it and nRF52 has 7 chips in it.
We will be mainly exploring nRF52 chips, though pattern of the peripheral features, SDK, RF protocols and their SDK are almost same for all series of Nordic SoC. So, if one gets command over one SoC of Nordic, can easily play with other family of SoC\’s.
nRF52 is newer then nRF51 and it is most widely used BLE family of SoC\’s. nRF52840 BLE SoC is the one we will be starting and exploring with.
nRF52840 SoC
Nordic Semiconductor provides 2 development kits on nRF52840 based SoC\’s
- nRF52840 Development Kit
- nRF52840 USB Dongle nRF52840 official Development Boards
NRF52840-Development Kit
We will be using and exploring nRF52840 DK, which has pins exposed to all peripherals of SoC. It is affordable single development board for Bluetooth 5, Bluetooth mesh, Thread, ZigBee, ANT, 802.15.4 and 2.4ghz proprietary protocols.
nRF52-DK
nRF Chips has an concept of Interface MCU. Interface MCU runs the Segger J-Link OB Interface Firmware that is used to program and debug the firmware of the nRF SoC\’s.
In NRF5280-DK, the one in center is interface MCU, the serial name of interface MCU in NRF52840-SDK is PCA10056. Actual IC at interface MCU is that of Atmel ATSAM3U2C.
Interface MCU on NRF52840-DK
When loading the projects from NRF5SDK, firmware\’s for different NRF-DK are been categorized according to Interface MCU only.
Thus if you can remeber when loading the Blink LED sketch on SES from NRF5 SDK, we can see this folder:
We will select the Interface MCU according to the DK which we are using.
Now nRF52-DK has on board Led\’s and on Board buttons as shown in below pic.
NRF52840 DK
From the Hardware Description of nRF52840-DK User Guide one can very well get to know about the Board. In this blog we will be controlling only the On-board LED\’s. Rest of the Board we will explore as and when needed or you can explore from user Guide.
Now for Powering on the DK and flashing the firmware on to the NRF52840 SoC. Do the things as stated in the below pic.
Now as we connect the USB cable to our host System. Board will power up and this window will pop up on the screen.
NrF52840-DK Powering up first time on connecting to Laptop Pop Window we get on our screen, as we connect the NRF52840 DK with Laptop
That\’s all been done so we are now ready to go and flash our Blink LED sketch into the NRF5840 DK from SES.
BLINK LED SKETCH for Nordiac NRF52840-DK
Now to open the BLINK LED project on the SES, do the following steps.
- Open the Segger Embedded Studio and we will see the dashboard on SES like this Segger Embedded Studio Dashboard
- navigate to file and then to open solution option Creating new solution on SES
- Now window will pop up to load our sketch into the SES. So now, Navigate to the directory where u have saved the NRF5 SDK Opening nRF5 SDK project on SES
- Go to examples/peripheral/blinky/pca10056/blank/ses. click on .emproject file and then open Opening nRF 5 SDK Blinky example project on SES
- Now our example blinky project will be opened on the SES. nRF5 SDK Blink example project on Segger Embedded Studio
- Now to build the project, click on Build and then to Build build_pca10056 option, you will see that our project will start building. Building nRF5 SDK Blinky example project on SES
- After successfully building of our blink project, it means that Environment setup, SDK setup and IDE are all done correctly. Now its time to flash our blink example into our NRF52840-DK.
- Click on Debug and then on Go option. Flashing the nRF5 SDK Blink LED peripheral example on NRF52840 DK
- Debug perspectives will open and now just start the sketch by clicking on triangle arrow button.
- That\’s all done and On Board LED\’s of NRF52840-DK will start blinking one by one.
- So that\’s all and we have successfully flashed the blink LED example onto our NRF52840-DK
Conclusion
In this blog we have got an overview of Nordiac SoC\’s, NRF SDK\’s. Setup the Software environment and understood the NRF58240-DK. In the end we have also run the BLINK led example project from SES using nRF5 SDK on NRF52840DK.
Further ahead
Further now we will be exploring UART and GPIO peripherals of the NRF52840-DK. But before that we will see how to create new project at SES without using the examples project.
Resources:
- Getting started with NRF 5 connect SDK: Getting started with nRF Connect SDK (nRF52 Series) (nordicsemi.com)
- Setting up NRF5 Connect SDK on SES and Vscode: Building and programming an application — nRF Connect SDK 1.8.99 documentation (nordicsemi.com)
- NRF5 connect SDK documentation: About the nRF Connect SDK — nRF Connect SDK 1.8.99 documentation (nordicsemi.com)
- NRF5 SDK resource: Introduction to Nordic nRF5 SDK and Softdevice – Getting Started – nRF5 SDK guides – Nordic DevZone (nordicsemi.com)
- nRF5 SDK vs nRF5 connect SDK: nRF Connect SDK and nRF5 SDK statement – Blogs – Nordic Blog – Nordic DevZone (nordicsemi.com)
Author: Kunal Gupta
Author