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

  • I added the function and structure and changed the main() like this:

    int main(void)
    {
        // Initialize.
        log_init();
        timers_init();
        leds_init();
        ble_stack_init();
        advertising_init();
    
        bsp_board_leds_init();
    
    	nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    	spi_config.ss_pin   = SPI_SS_PIN;
    	spi_config.miso_pin = SPI_MISO_PIN;
    	spi_config.mosi_pin = SPI_MOSI_PIN;
    	spi_config.sck_pin  = SPI_SCK_PIN;
    	APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));
    
    	while (1)
    	{
    		// Reset rx buffer and transfer done flag
    		memset(m_rx_buf, 0, m_length);
    		spi_xfer_done = false;
    
    		APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, NULL, 0, m_rx_buf, m_length));
    
    		NRF_LOG_FLUSH();
    
    		bsp_board_led_invert(BSP_BOARD_LED_0);
    
    		nrf_delay_ms(10);
    
            adv_update();
            advertising_start();
    
            if (NRF_LOG_PROCESS() == false)
            {
                //power_manage();
    
                NRF_LOG_INFO("Something sent.\r\n");
    
            }
        }
    }

    Sadly, I keep getting the same ERROR:FATAL in the LOG.

  • Any other idea? I found a nasty solution that solves that and the only remaining issue: deleting the APP_ERROR_CHECK() function that throws the error... I know, I know, that is not a solution, but for some reason the BLE advertising beacon is working and sending the data that I need it to send, so it can be a temporary solution.

    The other one was that I needed it to send at least 10 samples/second, for some reason, after erasing de error check now it works at full speed. Before, it was like stuck, it would be sending 3 readings per second and I could do nothing to change that.

    So, what are your feelings about this? Do you thing that the error could cause a corruption of the MCU or something worse?

  • yes it could be. If you have some special need to do error checking then only do that.. 

  • 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