This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to start working with nRF SDK and Segger Embedded Studio

Hello.

In last couple of days I've been trying to figure out how the whole SDK is structured and how to start developing essential applications using the Segger Embedded Studio.

I only have in my possesion an nRF51822 but 3 modules nRF52832 are on their way. 

So, to begin with I started with the last SDK which supports the nRF51 series which is the v12.3.0

1) I downloaded the "nRF CPU Support Package" from the Package Manager and made a new project. Selected my mcu and I got a main.c

2) I didn't want to open an example and start removing things out, so I opted to try adding the things I thought I need. I started addind the simplest functionality of GPIO. I haven't found any more relevant file apart from the "nrf_gpio.h". I included the file in my main.c then after trying to build the project I got an error. I traced down the file name to find where it is located inside the SDK and I placed the path into Project Options -> Preprocessor -> User Include Directories.

My folder structure looks like this

(my workspace)
|-- nRF5_SDK_12.3.0_d7731ad (SDK)
|-- Executable_1 (my project)
    |--- Application
          |--- main.c

And I added the line into the User Include Directories.

../nRF5_SDK_12.3.0_d7731ad/components/drivers_nrf/hal

3) Everything worked fine and I managed to run a simple blinky program when I added the nrf_delay header.

4) Things were more complicated when I tried to add a UART peripheral driver. I started by including the app_uart.h into my main.c
Needless to say how many files I had to look for in the SDK folder to manually include them into the User Include Directories. Moreover I ended up importing some other .c files which I don't know what they do, so I can sort them out properly.

Is there any more elegant way to do that?

Parents
  • hi... yeah, it seems that the way most people start is they copy an example project (for the basic kind of bluetooth functionality you want!) and move it out of the SDK then start to modify it into their own project...  it's probably the fastest and easiest, even though it's pretty hacky and a bit embarrassing to do.

    Keep in mind that to use bluetooth (which is really the whole point of even using these nRF parts instead of an STM32 or something else) you have to do even more for the project setup... you have to load the right softdevice in the right place, and have your app use the right memory ranges... 

    so yeah.. once you have your base bluetooth project copied, then you start loading up example projects for the peripherals you need, and see what files they include, and how they use the functions..  and copy those into your project too.. the sdk has some pretty deep dependency chains, that aren't always that obvious (or documented!) as you've discovered... and at least the example projects cover the important directories and the important c files for any given peripheral you want to use, so you can find things! 

  • Thank you very much for your answer and your time, Julian.

    I see there's no other way to work with the SDK too. I haven't read the code to tell if it's well structured. I haven't found any documentation about that either. At first glance, looking at the folders and the problems you can face when you try to do what I tried, it leaves the impression of a messy structure.

    I remember when I tried playing around with Atmel's ARM mcu. It took me like a few hours to start setting up custom boards on my own using their framework.

    I'll keep your advice and I'll try to extract a ble example that suits me best.

    However I'd be glad to see any documentation about the depedency chain that all those files contain.

    I haven't looked at SoftDevice documentation yet, I see there are a lot of versions for every chip.

Reply
  • Thank you very much for your answer and your time, Julian.

    I see there's no other way to work with the SDK too. I haven't read the code to tell if it's well structured. I haven't found any documentation about that either. At first glance, looking at the folders and the problems you can face when you try to do what I tried, it leaves the impression of a messy structure.

    I remember when I tried playing around with Atmel's ARM mcu. It took me like a few hours to start setting up custom boards on my own using their framework.

    I'll keep your advice and I'll try to extract a ble example that suits me best.

    However I'd be glad to see any documentation about the depedency chain that all those files contain.

    I haven't looked at SoftDevice documentation yet, I see there are a lot of versions for every chip.

Children
No Data
Related