0

Code portability between nRF51 and nRF52
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Code portability between nRF51 and nRF52

by Wi11y on Wed Feb 21, 2018 11:38 pm

I have a Adafruit nRF52832 feather board and was looking at one based on the nrf51822. On the Adafruit website it states that the code it not transferable between the two devices. Is it possible to write ardiuno IDE code that will work on both devices if you have the adafruit libraries for both boards installed and you are only using functions that both devices support? i.e: a HID keyboard.
The reason for asking is that the final usage for the project is automotive and I was looking at eventually using the nRF51824 AEC-100 rated device, but had started development using the nRF52832. There is no automotive device in the nRF52 range

Best regards,
Willy

Wi11y
 
Posts: 2
Joined: Wed Feb 21, 2018 11:27 pm

Re: Code portability between nRF51 and nRF52

by adafruit_support_mike on Thu Feb 22, 2018 1:05 am

You can, but it will basically be two programs in #ifdef blocks, so one set of code is compiled if the build target is an nRF51 and another set is compiled if the target is an nRF52.

The libraries are very different because of the hardware differences. The nRF51 is an external device that a microcontroller talks to through an SPI interface. The nRF52 is a microcontroller with radio hardware directly connected to it.

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code portability between nRF51 and nRF52

by Wi11y on Thu Feb 22, 2018 6:33 am

That makes no sense. The nRF51 uses a Cortex MO and the nRF52 is M4 based, both with soft radio devices built in. There is a fair range of extra features and peripherals in the nRF52 but isn't that what the arduino IDE is all about, making code portable?

Wi11y
 
Posts: 2
Joined: Wed Feb 21, 2018 11:27 pm

Re: Code portability between nRF51 and nRF52

by adafruit_support_mike on Fri Feb 23, 2018 1:48 am

If you want to stick to the simplest parts of the language and API, like Serial.print(), sure.. those are portable.

If you want to use specific features of the hardware, like BLE, which exist in one device and don't exist in the other, those aren't portable from one device to another. Go ahead and try to prove us wrong by writing even a basic cross-platform API that works across different chipsets if you think we're just making excuses.

adafruit_support_mike
 
Posts: 58874
Joined: Thu Feb 11, 2010 2:51 pm

Re: Code portability between nRF51 and nRF52

by yokotsuno on Sat Feb 09, 2019 11:06 am

This library could help you with that. Same code can work on both. https://github.com/I-SYST/EHAL
Development platform is Eclipse GCC. It is not too hard to setup. See these blog pages.

Writing BLE firmware with a few line of code : http://embeddedsoftdev.blogspot.com/2017/
Eclipse IDE with nRF5x series : http://embeddedsoftdev.blogspot.com/p/ehal-nrf51.html

yokotsuno
 
Posts: 3
Joined: Tue Nov 28, 2017 9:31 pm

Re: Code portability between nRF51 and nRF52

by 42volts on Fri Mar 29, 2019 8:46 am

Wi11y wrote:That makes no sense. The nRF51 uses a Cortex MO and the nRF52 is M4 based, both with soft radio devices built in. There is a fair range of extra features and peripherals in the nRF52 but isn't that what the arduino IDE is all about, making code portable?


Here is the thing, while you are technically correct, the adafruit response was also correct *within the limitations of the adafruit application of the nRF51 parts*.

The adafruit application of nRF51 is such that they pre-load the nRF51 with a custom written closed source blob, and they provide a library for interacting with that blob from an entirely separate device. For example, take the "Feather m0 bluefruit" device -- it includes a SAMD21 as the main MCU, and an nRF51 with that custom blob. The two are connected via SPI, but the SAMD is definitely in charge.

So as far as code portability goes, to an extent, yes, the code is portable between the two, but NOT code written using the adafruit doctored sdk. If you had written your code for the nordic nrf5 sdk, then you would be in a much better place to keep it for use on a nrf51.

42volts
 
Posts: 42
Joined: Sat Jan 19, 2019 11:20 am

Re: Code portability between nRF51 and nRF52

by hathach on Fri Mar 29, 2019 11:51 am

It is hardware design, on feather nrf51 it is co-processor, main mcu is samd. The reason is Nordic license is very strict back then, and we aren't allowed to public any of its code. nrf52 is fully open as you could see. The library is written with nrf52 in mind, but nothing prevent you to port it to nrf51. But that will take lots of work, you may want to take a lot at this repo here, it support nrf51
https://github.com/sandeepmistry/arduino-nRF5
https://github.com/sandeepmistry/arduino-BLEPeripheral

hathach
 
Posts: 1020
Joined: Tue Apr 23, 2013 1:02 am

Please be positive and constructive with your questions and comments.