📜 ⬆️ ⬇️

BLE from Nordic Semiconductor. Getting started with a stack using the nRF51822 chip


Hello.

For a while I had the idea to write an article about this stack, its features and applications using the nRF51822 chip. And the recent publication " BLE stack from TI " made me sit down and try to turn the idea into something tangible.

Nordic Semiconductor provides a very interesting, in my opinion, solution. On the one hand, there is a powerful chip on the ARM Cortex-M0 core, on the other hand, the constantly evolving stack software and a set of libraries included in the SDK.
')
Unfortunately, on Habré there are no articles on the subject of BLE on NORDIC, as in other matters, there are practically no articles in runet, so I hope that the article will be useful to those who are beginning to use the products of this company in the part concerning BLE, Those who are interested in Bluetooth technology and BLE in particular.

1. Iron


The nRF51822 chip considered by us from the side of the memory size is presented in 3 variants:

In this case, the RAM is divided into blocks and each block has its own power management. I focus on this attention, because when programming a chip you need to know that the application uses the upper half of the RAM, while the younger half is always used by the stack.

Depending on the stack version, the client software loading address may also change. It is also necessary to pay attention. If you incorrectly specify the address of the software download, the programmer will give an error, according to which you can never understand why it was not possible to flash the chip. The software download address is indicated in the specification for each version of the stack.

So, if you decide to work with BLE from NORDIC, then first of all you need to purchase one of the debugging kits. Here are some of them:
- nRF51822 Evaluation Kit (EK) is an independent platform for evaluation and prototyping, based on the nRF51822 chip.



The kit includes:


- nRF51822 Development Kit (DK) - platform dependent on the “Starter Kit”, makes it possible to create full-fledged applications using not only BLE, but also all the resources of the nRF51822 chip, like a microcontroller.


The kit includes:

By the way, “dependence” on the “Starter Kit” is not critical, if you know how to use a soldering iron or you have a prototype board and wiring.

- nRF51822 Starter Kit (SK) is a kind of “motherboard” to which you can connect the EK and DK to use all the features of the nRF51822 chip.



The kit includes 2 motherboards with cable sets.



Recently, the company does not recommend using EK and DK, since new debug kits have appeared: " nRF51 DK " and " nRF51 Dongle ", but I believe that EK and DK are still a very good tool for learning and prototyping.

Currently, my task uses nRF51822 DK without SK. Thanks to the connectors on the DK cards, you can connect any peripherals, such as LEDs, to indicate the presence of a connection or some kind of error, using connecting wires and a breadboard model. A feature of using DK without SK is that the DK board needs to be powered, and for this you need to know the pinout of the card's connectors.



It is in the document "nRF51822_Development_Kit_User_Guide". Due to the fact that I use the STM32L152-DISCOVERY debugging module as the “super-host” for the nRF51822, the 3.3V power supply is supplied from there.

Nuance: until you purchase one of the sets, you cannot download from the site neither the specification, nor the stack, nor the software, except for the software “nRFgo Studio” and documentation on the chips.

Each debugging kit has its own unique number (key) pasted on the box with the kit. After buying a set, you need to register on the site and in the user profile enter the key indicated on the box. After that, you will be available:


2. Software offered by NORDIC




3. Development Tools


For programming, you can use both paid and free development tools. NORDIC suggests using Keil MDK-ARM, IAR, as well as any IDE that allows you to work with GCC ARM. To work with GCC, a document called “nAN-29 nRF51 Development with GCC and Eclipse Application Note” is proposed, which describes suggestions for developers who want to use Eclipse, GCC and GDB.

NORDIC thinks Keil is preferable to use, and even the “nRF51 SDK” installer integrates the SDK into Keil, making it easier to create an application project. All examples in the SDK have Keil format project files.



4. SoftDevice stack



The stack is offered in 3 versions.


The API of any of the stack options allows you to control both the BLE controller and the host, i.e. and other peripherals included in the chip. It is more correct to say this: if you use the SoftDevice stack, then the rest of the periphery is managed through the stack API and it controls what and when to use it. Naturally, the chip can be used without any stack at all, just like a regular microcontroller.

The release information for the next version of the SDK always indicates the supported stack version. This is very important, because the first thing a programmer encounters is the impossibility to flash his program due to the inconsistency between the SDK version and SoftDevice. For example, the SDK version 6.1.0 works with the following stack versions: S110 - 7.0.0, 7.1.0; S120 - 1.0.0.

5. Firmware stack and client application.



Due to the fact that the stack is offered only as a binary firmware file, the question arises: how to work with the chip if you need to sew both the stack and your program?




As can be seen from these two figures, the stack is sewn to the bottom of the flash memory and uses the lower half of the RAM, starting at 0x2000000. The application is sewn into flash memory, starting from the address CODE_R1_BASE uses RAM from the address RAM_R1_BASE.

The variables CODE_R1_BASE and RAM_R1_BASE differ depending on the stack version.

The stack is sewn using the “nRFgo Studio” program once, after which you can write your application and sew it with either “nRFgo Studio” or, more conveniently, using Keil.




The stack HEX file is sewn once, after which you can write your application and sew it or “nRFgo Studio” or, more conveniently, using Keil.

Here is an example of setting up memory in Keil for S110 v.6.0.0 stack:



The CODE_R1_BASE is 0x16000, and the RAM_R1_BASE is 0x20002000.

And here is an example of setting memory in Keil for the S120 v.1.0.0 stack:



The CODE_R1_BASE is 0x18000, and the RAM_R1_BASE is 0x20002800

6. Conclusion


The SDK offers a large number of examples of using the nRF51822 chip both as a simple microcontroller and as a stack. Thanks to the examples, you can quickly master the programming of the chip in parallel by studying all the subtleties of the SDK, and there are not enough of them.

NORDIC has created a good forum where you can get an answer to almost any question. Employees of the company often answer questions themselves and rather quickly.

Thank you for reading my article to the end. If you are interested and I pass the sandbox, then in the next article I will talk about the features of implementing client software using the SDK stack.

I would like to wish you good luck and success in mastering and using Nordic Semiconductor products, I personally like their solutions.

Thanks for attention.

Source: https://habr.com/ru/post/246241/


All Articles