The nRF51822-mKIT is a low cost ARM mbed enabled development board for Bluetooth® Smart designs with the nRF51822 SoC. The kit gives access to all GPIO pins via pin headers ...

Experiments with mbed code on non-mkit nRF51822 hardware

07 Jun 2014

Just for the fun of it, I bought a cheap nRF51822 breakout module on eBay to see if it was able to run mbed code. Initially it didn't work, but after some tweaking I was able to run the health thermometer example. The following steps were taken:

Please note that some of these steps involve tools that are not part of the nRF51822-mkit!

  • Changed the following line to use the internal 32kHz oscillator instead of an external 32kHz crystal as used on mkit:

btle_init code change in BLE_API_Native/hw/nRF51822n/btle/btle.cpp

  //SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
  SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);
  • Compiled the project to create a target hex file.
  • Connected a Segger JLINK Lite dongle to the target through a 2.54 - 1.27 mm adapter and some wiring.
  • Started nRFGo Studio.
  • Erased the target and downloaded the hex file with nRGGo Studio and Segger JLINK lite using "Erase all"/"Program application".
  • Disconnected JLINK and restarted the target.
  • Worked with the nRF Toolbox!

There are probably easier ways to accomplish this! A separate CMSIS-DAP interface maybe? :)

/media/uploads/tand/nrf51822_prog_setup.jpg /media/uploads/tand/nrf51822_module.jpg

17 Jun 2014

Hi, a side question: where did you get the Segger J-link lite cortex M but couldn't find anywhere selling this one.

17 Jun 2014

I tried to load the example code Heart Rate to the Evaluation Kit (non-mbed platform). The Master Control Panel is able to detect the advertising device. However, i can't get it to connect with the EV board and keep getting this error: /media/uploads/littledino2112/capture.png

17 Jun 2014

By the way, i already changed the LFCLKSRC to internal RC source.

23 Jun 2014

Hoang Nguyen Van wrote:

Hi, a side question: where did you get the Segger J-link lite cortex M but couldn't find anywhere selling this one.

The Segger J-link lite adapter is part of the nRF51822 Development Kit from Nordic Semiconductor. You should be able to find it at major distributors that stock their development products.

24 Jun 2014

Thanks Tord, i just realized that it came with the Development board. Since i already bought an Evaluation Kit, i'm not going to buy the DK just for the Debugger. I'll look for another one on the market. By the way, I was trying to upload the sample code to the EK board. The blinking sample works fine. But for the Heart Rate one, the board can advertise but i can' connect to it. The error was posted on my previous thread. Do you have any idea? P/S: I use the default config for LFCLKSRC since the EK has an external 32khz crystal.

13 Jul 2014

Are the pins on this nRF51822 breakout module 2mm or 2.54mm spacing ?

Has anyone manged to use an LPC1549/LPC11U68 and the code as in http://bril-tech.blogspot.co.uk/2014/06/bluetoothsmartmbed-3.html to upload code to their module ?

18 Jul 2014

Thank you Andersson .

I did not understand? "btle_init code change in BLE_API_Native/hw/nRF51822n/btle/btle.cpp" can you please tell me the modified code : carthagotata@yahoo.fr.

Thanks Nouri

18 Jul 2014

Thank you Andersson .

I did not understand? "btle_init code change in BLE_API_Native/hw/nRF51822n/btle/btle.cpp" can you please tell me the modified code : carthagotata@yahoo.fr.

Thanks Nouri

18 Jul 2014

hi I would also test this code with evaluation board. but I have not done? if you did can you tell me please the modest? or send me de change.

Thanks Nouri

04 Aug 2014

David Fisher wrote:

Are the pins on this nRF51822 breakout module 2mm or 2.54mm spacing ?

The pins use 2mm spacing.

04 Aug 2014

Dani Wurf wrote:

I did not understand? "btle_init code change in BLE_API_Native/hw/nRF51822n/btle/btle.cpp" can you please tell me the modified code

Replace the line below in the BLE_API_Native/hw/nRF51822n/btle/btle.cpp file:

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);

With the following line:

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);
05 Aug 2014

@Andersson Thank You very much

06 Aug 2014

Tord Andersson wrote:

The pins use 2mm spacing.

thanks just got one the other day. Found these adapters to help prototype with http://www.bitwizard.nl/catalog/product_info.php?cPath=35&products_id=142

Do you know of any other sort of suitable adapter ?

Tord Andersson wrote:

There are probably easier ways to accomplish this! A separate CMSIS-DAP interface maybe? :)

Have you seen the new NXP mbed boards https://mbed.org/platforms/LPCXpresso1549/ which can program an external target.

There is code to flash the board with here http://bril-tech.blogspot.co.uk/2014/06/bluetoothsmartmbed-3.html

06 Aug 2014

I suppose you can use two of these as well for 2 mm to 2.54 mm connectors ( 2.5 inch HDD to 3.5 inch HDD IDE adapter ) Unfortunately , some pins are routed to power and ground .. but you can use at least the half part

/media/uploads/bitman/2.5_inch_hdd_ide_adaptor_to_3.5_inch_ide.jpg

http://www.ebay.com/itm/IDE-2-5-to-3-5-Hard-Disk-Converter-Adapter-Power-Cable-44-pin-to-IDE-40-pin-/181334795497

Regards , Christos

08 Aug 2014

Hey

I would use cheap nRF51822 breakout module for example SHT15-Example or SHT21-Example or SHT-Test? can you help me? because only BLE_Health_Thermometer_Blog has btle.cpp .

Thanks Nouri

13 Aug 2014

I used the pin 6 and 7 for the BLE_Health thermometer with NRF Break Out Board. how do you do pin assignment? state 20 and 22.

Thanks

13 Sep 2014

Dani Wurf wrote:

how do you do pin assignment?

Sorry for the late reply! Initially I simulated the temperature in code, followed by tests with DS1820 and DHT22 sensors. For the DS1820 sensor I added this:

#include "DS1820.h"
...
DS1820 probe(P0_0);
...
probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
temperature = probe.temperature();

It seems however, that the current setup does not show temperatues below 0 degrees Celsius in the nRF Toolbox. Have not yet went any deeper into this, to see if the problem is caused by the mkit side or the nRF Toolbox though.

30 Sep 2014

For anyone interested there is now a board available to plug these modules into http://www.wvshare.com/product/NRF51822-Eval-Kit.htm

http://www.wvshare.com/img/devkit/accBoard/BLE400/BLE400-4.jpg

08 Oct 2014

Hi,

the steps mentioned in the first post don't work for me anymore (they were in serveral weeks in the past). After hitting the "Program" button in the nRFgo Studio, an error message pops up, stating: "programming failed: failed to read hex file".

Looking inside the hex file with an editor, the hex file also doesn't seem to be a valid hex file, it looks like a binary file. File downloaded in the past looked like described here: http://en.wikipedia.org/wiki/Intel_HEX

Has there been any change in the compiler settings? Is there a way to still get a valid hex file?

Thanks

08 Oct 2014

Norman Pohl wrote:

After hitting the "Program" button in the nRFgo Studio, an error message pops up, stating: "programming failed: failed to read hex file".

Looking inside the hex file with an editor, the hex file also doesn't seem to be a valid hex file, it looks like a binary file. File downloaded in the past looked like described here: http://en.wikipedia.org/wiki/Intel_HEX

Has there been any change in the compiler settings? Is there a way to still get a valid hex file?

I started playing with a non-mbed nrf a few days ago and also noted the non-hex file error a couple of times. I use a Segger J-Link SWD programmer. It seems to be a compiler issue. I forced a recompile (build-all) and the same source code compiled and downloaded just fine.

23 Oct 2014

Wim Huiskamp wrote:

I use a Segger J-Link SWD programmer. It seems to be a compiler issue. I forced a recompile (build-all) and the same source code compiled and downloaded just fine.

Thanks, that worked! :)

18 Nov 2014

David Fisher wrote:

For anyone interested there is now a board available to plug these modules into http://www.wvshare.com/product/NRF51822-Eval-Kit.htm

I have one of these motherboards and three of the modules. Besides trying to by a Segger, is there any other way to program these modules? For example, via a STM32F4-Discovery board, which has a ST-Link SWD programmer on-board, or by buying the nRF51822-mKIT and using that?

Thanks, David Neophyte to nRF51822/OpenSDA/etc.

18 Nov 2014

David Harris wrote:

I have one of these motherboards and three of the modules. Besides trying to by a Segger, is there any other way to program these modules? For example, via a STM32F4-Discovery board, which has a ST-Link SWD programmer on-board, or by buying the nRF51822-mKIT and using that?

Programming should work through nRFkit when you have access to the SWD port of the programmer part. You should then also have the mbed drag-and-drop capability for programming.

The SWD programmer on the ST32F4 discovery and similar onboard programmer devices may not work since they probably need to select the nRF51822 as target to select the correct flash algorithm and they may not accept the hex file that is typically produced by the mbed compiler for the nRF51822. These programmers are often locked to one type of target devices. Maybe there is some more flexibility through the CMSIS interface in combination with a tool like Keil.

19 Nov 2014

David Harris wrote:

I have one of these motherboards and three of the modules. Besides trying to by a Segger, is there any other way to program these modules? For example, via a STM32F4-Discovery board, which has a ST-Link SWD programmer on-board, or by buying the nRF51822-mKIT and using that?

You could try to use one of the new nxp boards LPC1549/LPC11U68 and the code as in http://bril-tech.blogspot.co.uk/2014/06/bluetoothsmartmbed-3.html to upload code to the module ?

There is also the LPC-Link 2 board which I presume could be programmed with the same code as LPC1549/LPC11U68 as they both have LPC-Link 2 and lpc43xx ? This would be a cheaper route as far as board cost and also it wouldn't require a 10 to 20 pin converter.

Or you could try one of the new Nordic nrf51-dk boards which can program and debug external targets according to this http://www.cnx-software.com/2014/10/29/nordic-semi-announces-nrf51-dk-arduino-compatible-board-and-nrf51-dongle-with-bluetooth-smart-ant-and-2-4ghz-connectivity/

I think I'll be going with the latter suggestion as I won't have to compile my own code.

Could you please tell us which solution you decide on and how it works and perhaps a photo of your setup.

many thanks.

11 Dec 2014

Tord Andersson wrote:

Replace the line below in the BLE_API_Native/hw/nRF51822n/btle/btle.cpp file:

1 SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); With the following line:

1 SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);

Hmm. So if I was testing with the mbed_blinky example, would I have to import the BLE_API library and find this file? Because I tried that and I don't seem to see it.

Is there a way to set this in main.cpp so we don't have to fool around with the library files?

Thanks for the forum post, and the help!

12 Dec 2014

Hopefully you'll reuse your platform for several applications; it would be better to have the initialization code early on in the startup sequence so that your applications won't need to bother with it.

06 Dec 2015

I know this thread has been dormant for nearly a year, but just in case its of any use to anyone reading this...

There are at least 2 other cheap ways to upload to the nRF51 (eg that module from WaveShare which is described above...)

1. Black Magic Probe. This is Open Source SWD programmer based on the STM32F103 or other hardware.

I have a version of the BMP including precompile binaries for several cheap STM32 boards.

https://github.com/rogerclarkmelbourne/blackmagic/tree/master

You will of course need a STM32 board like a Maple mini, but you can get them for around $6 from eBay

2. STLink You can buy these SWD programmers very cheaply, on eBay etc, and you can use OpenOCD to program via STLink.

I initially used STLink and OpenOCD but the setup is a bit complex (though it is documented on various sites, just search for "OpenOCD STLink")

BTW.

The modules I have which look similar to the one in the picture, now have the 32kHz crystal, but I"m trying to use a different module, which is half the size and doesnt have the 32khz Crystal

However at the moment even if I make the changes describe above, to use the internal oscillator and change the soft device timing stuff, still don't work :-(

23 Feb 2016

Roger Clark wrote:

BTW.

The modules I have which look similar to the one in the picture, now have the 32kHz crystal, but I"m trying to use a different module, which is half the size and doesnt have the 32khz Crystal

However at the moment even if I make the changes describe above, to use the internal oscillator and change the soft device timing stuff, still don't work :-(

Do you have a link to the module you are referring to ?

On your excellent website http://www.rogerclark.net/ you have a tutorial on using this module with arduino perhaps you could do a version for mbed ;-)

23 Feb 2016

David

I bought some of these http://www.wireless-tag.com/index.php/Product/dis/25.html (from AliExpress). They come with some AT based command firmware, and they are read protected, so you need to clear them before you can use them, which I found a bit tricky to do, as JLink didnt seem to be able to communicate with device at all while it was read protected. From what I recall I ended up using my Black Magic Probe to write some values to specific memory locations which forced a total erase of the device (Sorry, I should have written down the link, but at the time I was so relieved to have not bricked the device, I didn't think to document what I'd done)

I then managed to get MBED to to work on that module, by selecting the HRM1017 module for the project, as that module doesn't have the 32kHz crystal either.

Unfortunately I've been so busy with work, that I've not had time to write any more blog entries or do any more YouTube videos.

I have enhanced my Arduino for NRF51822 repo and you can no upload to the Waveshare (http://www.waveshare.com/wiki/Core51822 ) module using JLink as well as Black Magic Probe, but I've not had time to publicise this on my blog etc :-(

BTW. The Wireless-tag modules are OK, but because they don't have the 32kHz crystal it makes them useless for a lot of low power applications, as the power consumption in sleep is much higher than the modules with the 32kHz crystal.

I actually ended up buying a bag of 32kHz crystals and some 12pF capacitors, which I solder onto those boards, so that they can be programmed via the Arduino IDE, but mainly to get the current consumption down.

You need to log in to post a reply