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

SPI communication and BLE advertising data with nRF52 DK

Hi everyone!

I have already developed a couple projects in nRF52 DK and the result was quite messy. I want to make it right this time and that's why I am requesting your help.

I am using nRF52 DK and SDK 13.0.0. and Eclipse Mars 2 (C/C++) with the setup explained in this Devzone Tutorial.
My goal is to create a project starting from some examples, modifying and merging them. I intend to comunicate with a SPI peripheral and send the recieved data through BLE advertising mode (broadcast).

I have compiled and tested the SPI example and it works just fine. Now, I need to send that data over BLE advertising. The requirement is it to be sent at least 10 times every second.

I would be very grateful if you could guide me on this. Some pages that I should read, any example that broadcasts data over BLE, any question already answered on this topic (I have searched and I did not find that much), any help will be very welcome. I really want to learn how to use Nordic hardware but my previous experience has only been frustrating so far.

Thank you so much for your time!

AGB

Parents
  • I am now trying to merge both main.c (the one from the "ble_app_beacon" example and the other from "spi") files into just one project. I soon started to get errors, so my first approach was going to the sdk_config.h file to enable the spi. And then some errors like "SPI_SS_PIN is not declared " started to pop up.

    These defines are normally placed in the sdk_config.h file as well, but they are not. I thought that the sdk_config.h file was a macro equal for all the projects and examples and you could configure it, but the ble_app_beacon's sdk_config.h file does not have the declarations of SPI_SS_PIN, SPI_SCK_PIN,... Is that normal?

    I started to define all of them by hand. And now I only have 2 errors: undefined reference to 'nrf_drv_spi_init' and undefined reference to 'nrf_drv_spi_transfer'. Both of this functions are declared in nrf_drv_spi.h which, by the way, is included in my project. Why does Eclipse not recognise them? Or what is the problem?

  • Yes you can add you #defines for spi in you sdk_config file for ble_app_beacon example. It is normal. Try to setup same files and libraries which you are using for simple spi example into your beacon example. And make sure you have added path to all your libraries and files.

    have you included all required files for spi into main.c?

Reply Children
  • Everytime that I create a new project i follow the steps of the Devzone Tutorial (Propierties > C/C++ General > Preprocessor Include paths, Macros, etc and change the CDT GCC Build Outparser and CDT GCC Built-in Compiler Settings Cross ARM). I am not an expert, so I may be wrong but I think that is for avoiding erros in includes, isn't it?

    And yes, I have added the spi's includes to the main.c file of the ble_app_beacon.

  • I got rid of the problem with "undefined reference to 'nrf_drv_spi_init' " and "undefined reference to 'nrf_drv_spi_transfer' ". Turns out that I hadn't added the lines:

    $(SDK_ROOT)/components/drivers_nrf/spi_master \

    $(SDK_ROOT)/components/drivers_nrf/spi_master/nrf_drv_spi.c \

    To the Makefile. Now it compiles perfectly, I just need to fill the advdata info with the readings from the spi and that should be it.

  • Hi,

    I am facing same problem. SPI is not working with ble_app_beacon example. I am using Segger Embedded Studio, Nrf52832 DK and Windows10. I have unzipped the nrf52 SDK 14.2.xx in the default Document folder. where should I add these two lines in my working setup to get ride of these errors.

    Thanks in advance for the help,

    --vijay

  • Hi Vijay, you must edit your Makefile for this project. If you just copied the folder of the example, you must go to:

    ...\examples\ble_peripheral\ble_app_beacon\pca10040\s132\armgcc

    Then, you must add the line: $(SDK_ROOT)/components/drivers_nrf/spi_master/nrf_drv_spi.c \

    To the list "# Source files common to all targets"

    And the line: $(SDK_ROOT)/components/drivers_nrf/spi_master \

    To the list "# Include folders common to all targets"

    Then save everything and rebuild the project. Those errors should dissapear.

    Hope this works for you!

    AGB

Related