SPI communication between Arduino and nrf51dk

Manuja gravatar image

asked 2016-11-12 00:44:33 +0100

Hi, I want to send data from arduino to nrf51dk which will then use uart service to send the data over bluetooth. I want to use SPI communication between the two microcontrollers. Can I get any working example combining SPI and nus-uart?

edit retag flag offensive close delete report spam

1 answer

Sort by » oldest newest most voted
awneil gravatar image

answered 2016-11-12 13:58:51 +0100

You need to learn to break problems down into their constituent parts.

In this case, two parts should be immediately apparent:

  1. SPI;
  2. NUS-UART.

It should be easy enough to find examples of each - so get each one working separately, and then bring the two together.

edit flag offensive delete publish link more


@awneil: Hi, i added the spi slave example to nus-uart but it is not working. I am not getting any error but spi section is not working though it works independently without nus(checked using spi-master). I added these two functions to nus-uart, and called spi_slave_init() in main() -

       static void spi_slave_init   (void)  
               nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG(SPIS_INSTANCE);
               spis_config.csn_pin               = SPIS_CS_PIN;
               memset(m_rx_buf, 0, m_length);
               APP_ERROR_CHECK(nrf_drv_spis_init(&spis, &spis_config, spis_event_handler));
               spis_xfer_done = false;
               APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, m_tx_buf, m_length, m_rx_buf,     m_length));

            while (!spis_xfer_done)

           void spis_event_handler(nrf_drv_spis_event_t event)
           if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
                          spis_xfer_done = true;
                          NRF_LOG_PRINTF(" Transfer completed. Received: %s\n",m_rx_buf);

                  if(SPI_BUFFER_SIZE <= 20)
                    ble_nus_string_send(&m_nus, &m_rx_buf[0], SPI_BUFFER_SIZE);


Manu ( 2016-11-13 03:22:21 +0100 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower


Asked: 2016-11-12 00:44:33 +0100

Seen: 192 times

Last updated: nov. 12 '16