nRF52382 is a BLE micro-controler based on a 32b Arm M4 core operating at 64MHz. It includes 512kb of flash memory and 64kb of RAM with a price about 2,80$.
It supports BLE (Bluetooth Smart) and ANT RF protocol. It also includes a NFC-A tag. NFC can wake up device and allow easy bluetooth pairing.
Device allows Over-the-Air Firmware Upgrade. It also have different SoftDevice (protocol stacks) with BLE or ANT8 or both.
By including internal Oscillators, power supply elements and Rf elements, this chip is a low cost solution for building IoT.
nRF52832 will be available Q1 2016 but development kit preview are available. (note – this post has been kept as a draft for a too long time !! )
Now, let’s read the next part for how to quick start with the development kit.
Some detailed specification
- Core energy consumption : 3,4mAh @ 64Mhz on flash / 1,9uA Sleep mode RTC running with 32kB of RAM refreshed.
- ADC : 12bits 200 ksps with 8 configurable channels
- Sensors : Temperature
- PWM : 3 PWM with 4 channels
- Timers : 5 x 32b timers
- Interfaces : 3x SPI / 2x I2C / 1x UART
- Peripherical : AES HW encryption / 3x RTC
- Packages : QFN48 (6×6 mm) or WLCSP (BGA) (3×3,2 mm)
Full specification can be obtained here
Getting start with SDK
The nRF go Studio for windows contains tools like Jlink and other programming / debugging elements.
No development environment is provided by Nordic and you have a choice between Keil (>3000€), IAR (>3000€) ; both commercial version have free but limited version. The last option is GCC for free. Usually Gcc is less optimized than IAR or Keil in terms of generated code : code is larger and slower. As a consequence you have a certain over consumption in an energetic point of view.
Option #1 – work with Keil environment
I don’t know if there is something to describe with Keil as you just have ton install Keil last version. then select in the package manager the Nordic nRF52 component and install whatever you need as package. Then you start the Keil environment, and open an existing project like C:\nrf52\sdk\examples\peripheral\blinky\pca10036\blank\arm-nopack\ ; the needed other pack will be installed automatically by the package manager, so you compile and your are done.
The problem of Keil is the compilation size limitation of 32KB in the free version. Thanks to the use of SoftDevices with nRF52 you can make a lot of things with a 32KB code but as soon as you will have a complex code this limitation is starting to be a problem.
For this reason if you do not want to buy the expensive Keil software you can use Eclipse & GCC
Option #2 – work with Eclipse / GCC free environment
So let’s start to install GCC version on windows ! this tutorial is based on this one. What you have to know is that the integration is quite poor and you will have to make a lot of project configuration manually. I was expecting Nordic Semi to deliver a better project configuration template to make it really simpler for us … but they don’t.
- First step is to download the ARM-GCC toolchain from launchpad this will install all the compiler stuff from gcc working for any ARM target.
Then run the installation and set path to : C:\nrf52\GNU Tools ARM Embedded\vvvvvvv
Then get Gnu-Make utility and the associated dependency.zip file and unzip both into C:\nrf52\GNU Tools ARM Embedded\vvvvvvv\ and merge the directories. Then you can do the same with Gnu-CoreUtilities
- Get the nRF52 SDK from the download section (NRF5-SDK-v12.zip) and unzip it into c:\nrf52\sdk\
- Now update the path in the Makefile.windows file
Edit file C:\nrf52\sdk\components\toolchain\gcc\Makefile.windows and change the blue part and check the red part (was not correct for me)
GNU_INSTALL_ROOT := C:/nrf52/GNU Tools ARM Embedded/5.4 2016q3 GNU_VERSION := 5.4.1 GNU_PREFIX := arm-none-eabi
- Add the binary path (C:\nrf52\GNU Tools ARM Embedded\5.4 2016q3\bin;) in you %PATH% environment variable
- Now you can try a first compilation but going to C:\nrf52\sdk\examples\peripheral\blinky\pca10040\blank\armgcc\ and type make command
Now we can install Eclipse
- Download the Eclipse (>Neon 3) environment for C/C++ development from here
- Select package Eclipse IDE for C/C++ Developers
- Move the files in c:\nrf52\eclipse
- If you do not have a Java environment installed
- Download Java Runtime Environment (JRE) from here.
- Install the JRE but change the destination directory for c:\nrf52\eclipse\jre
- Now you can start Eclipse and create the workspace in this directory : C:\nrf52\workspace
Now install GNUARM plugins
- In Eclipse, go to Help menu and click on Eclipse MarketSpace
- In the “Find” field, type “ARM” and click on GO button
- Select GNU ARM Eclipse X.Y.Z (actual version is 3.4.1) then click on install
- Select to install
- Cross Compiler
- Generic Cortex M template
- Packs (Experimental)
- JLink Debugging
- Accept license (if you wish) and install after installing, Eclipse will stop & start
Install the nrf52 Packages
- This is optional ; as actually the SDK delivred by Nordic is 12 but the packs are limited to version 11, I do not recommend to install them.
- Close the welcome page. On top you will see the package icon :
- Click on it then click on the refresh button on the new windows appearing.
- The package list refresh will take a while (5-10 minutes)
- Then, on the right select :
- Nordic Semi
- nRF52 familly.
- Nordic Semi
- This will give you a list of available pack. You can install
- NRF ARM Device Familly Pack by clicking on the Package icon (with a going down arrow).
Configure Eclipse
- Once restarted, configure the gcc toolchain location in Windows / Preference window
- Verify segger Jlink configuration : check in preferences >> Run/Debug >> SEGGER J-Link. You should have something like :
Create the blinky project (simple version)
- Create a new Project with menu File >> New >> C Project
- Create some folder for the project and copy the file from the blinky sdk example as followed
The different files can be found in the sdk/examples/peripherical/blinky/
main.c -> src/main.c pca10040/blank/armgcc/blinky_gcc_nrf52.ld -> blinky_gcc_nrf52.ld pca10040/blank/armgcc/Makefile -> Makefile pca10040/config/sdk_config -> inc/sdk_config
- Now we have to configure the build to execute the Makefile
- Edit the Makefile
OUTPUT_DIRECTORY := _build SDK_ROOT := ../../sdk PROJ_DIR := . $(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
$(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd/nrf_soc.c \
$(PROJ_DIR)/src/main.c \
$(SDK_ROOT)/external/segger_rtt/RTT_Syscalls_GCC.c \
$(SDK_ROOT)/components/drivers_nrf/i2s \
$(PROJ_DIR)/inc \
$(SDK_ROOT)/components/libraries/gpiote \
$(SDK_ROOT)/components/drivers_nrf/pwm \
../config \ <= remove this line
$(SDK_ROOT)/components/libraries/usbd/class/cdc \
- You can now compile your project with the compile tool
- The next step is to launch Flashing by creating a new build target
- This done you can compile and flash a source code but all the dependency in the editor will cause problem and syntax highlighting because the Makefile references (sdk) are unknown for Eclipse. You need to add in eclipse the related includes. To make it you can go to the project preference and add them manually
Due to the nrf52 sdk organization this phase can be really long and another possibility is to manually edit the .cproject file once you have closed the project in the UI. This way you can more quickly import the required include path.
- This is not totally sufficient because you also need to report the #define
- Now you project may not report syntax error.
Conclusion
Working with eclipse with nRF52 is more complex than with solution than Keil & IAR but once configured it works well and save money. nRF52 sdk is globally a mess.
The presented way to build a project on Eclipse from an existing example from the sdk is the faster way and safer way. Another way is to configure the project to not have to use an external Makefile. This method is really longer when you do it for the first time and for this reason I’ll detail it in a second coming post.
Hi Paul,
thanks for this tutorial that helps me a lot. But I have just a little feedback : gnu arm plugins
GNU ARM Eclipse no longer exists, it’s now gnu mcu eclipse, and it won’t install from marketplace.
I’ve used instead the following menu : Help -> Install New Software -> Add
In name I’ve written gnu-mcu-eclipse, in location https://dl.bintray.com/gnu-mcu-eclipse/v4-neon-updates/ and evrething worked fine 😉
Thank you once again for your work.
Lionel
Thank you Lionel for enriching this post 😉
Great one just came across this from a quick google search(been looking for it before but couldn’t find it.
Now I have an ST link V2 dongle that I want to use to flash a custom nrf52832 pcb I made with eclipse followed this tutorial:
devzone.nordicsemi.com/tutorials/7/
up to “Flash download” but had issues there.
How do you suggest I go on about with this setup?
I’d be happy if we could set up a live chat how ever you want to discuss it I’ll give you a couple of different PCBs sample from the production as a gift for you maybe to use and review sins they can be used as a cheaper DK.
Thanks.
please what do you mean by :
*Add the binary path (C:\nrf52\GNU Tools ARM Embedded\5.4 2016q3\bin;) in you %PATH% environment variable