<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70380/receiving-data-with-ble-and-sending-them-with-spi-to-a-microcontroller-which-is-used-to-send-data-to-pc-by-usb-connecti</link><description>Hi, 
 I am using a nRF52832 module to receive some data from another nRF52832, which is sending the digitalized data to the receiver. My receiver consists of a nRF52832 module connected to a STM32f103c8t6 MCU through SPI. I want to receive data with nRF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Feb 2021 07:47:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70380/receiving-data-with-ble-and-sending-them-with-spi-to-a-microcontroller-which-is-used-to-send-data-to-pc-by-usb-connecti" /><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/293240?ContentTypeID=1</link><pubDate>Mon, 08 Feb 2021 07:47:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d79339d8-59ac-4dd7-8ddf-afb48daa5640</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;What do you see on the SPI lines? Is CS asserted and is the CLK still running or is the transaction ended after the data has been sent&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/293200?ContentTypeID=1</link><pubDate>Sat, 06 Feb 2021 12:28:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1af44bd4-d11d-4ed4-982d-8c06273565cb</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Hi, the setting for radio is&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define NRF_ESB_DEFAULT_CONFIG {.protocol               = NRF_ESB_PROTOCOL_ESB_DPL,         \
                                .mode                   = NRF_ESB_MODE_PTX,                 \
                                .event_handler          = 0,                                \
                                .bitrate                = NRF_ESB_BITRATE_2MBPS,            \
                                .crc                    = NRF_ESB_CRC_16BIT,                \
                                .tx_output_power        = NRF_ESB_TX_POWER_0DBM,            \
                                .retransmit_delay       = 250,                              \
                                .retransmit_count       = 5,                                \
                                .tx_mode                = NRF_ESB_TXMODE_AUTO,              \
                                .radio_irq_priority     = 1,                                \
                                .event_irq_priority     = 2,                                \
                                .payload_length         = 32,                               \
                                .selective_auto_ack     = false                             \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and the priority for SPI was set to 6, but I changed it to 3 and nothing happened.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;also I put a breakpoint in SPI handler but it seems that the program never enters the handler.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/292862?ContentTypeID=1</link><pubDate>Thu, 04 Feb 2021 10:15:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67717d58-f072-4255-b53a-d54c9321139a</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What do you see on the SPI lines? Is CS and the CLK still running or is the transaction ended after the data has been sent?&lt;/li&gt;
&lt;li&gt;What priority are you running the modules at? Could you try to increase the SPI priority?&lt;/li&gt;
&lt;li&gt;Set a breakpoint in the SPI handler, and then debug your application. Does the program hit the handler?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/292656?ContentTypeID=1</link><pubDate>Wed, 03 Feb 2021 11:41:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08eb0acd-2d1e-4990-a231-0cbbf57b8584</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;Hi, the problem with the spi connection is fixed. I&amp;nbsp;changes the master and slave. I rewrote the spi example in sdk17 as below. I receive the data by radio and then I will send it over SPI. but the problem is even that the data is send and I received it in stm32 by spi, but the nrf can not pass the below loop:&lt;/p&gt;
&lt;p&gt;while (!spi_xfer_done)&lt;br /&gt; {&lt;br /&gt; __WFE();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;NRF_LOG_FLUSH();&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know why this happen. can you help me?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
 
#include &amp;quot;nrf_esb.h&amp;quot;

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;sdk_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_esb_error_codes.h&amp;quot;
#include &amp;quot;nrf_error.h&amp;quot;


#include &amp;quot;nrf_drv_spi.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;string.h&amp;gt;


#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

#define SPI_INSTANCE  0 /**&amp;lt; SPI instance index. */
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */
static volatile bool spi_xfer_done;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */

#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[32] = {0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[sizeof(m_tx_buf)+1];    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */
int k=0;
/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
    spi_xfer_done = true;
    NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}

/**********  NRF ESB RX begins **********/
uint8_t led_nr;
nrf_esb_payload_t rx_payload;

/*lint -save -esym(40, BUTTON_1) -esym(40, BUTTON_2) -esym(40, BUTTON_3) -esym(40, BUTTON_4) -esym(40, LED_1) -esym(40, LED_2) -esym(40, LED_3) -esym(40, LED_4) */

void nrf_esb_event_handler(nrf_esb_evt_t const * p_event)
{
    switch (p_event-&amp;gt;evt_id)
    {
        case NRF_ESB_EVENT_TX_SUCCESS:
            NRF_LOG_DEBUG(&amp;quot;TX SUCCESS EVENT&amp;quot;);
            break;
        case NRF_ESB_EVENT_TX_FAILED:
            NRF_LOG_DEBUG(&amp;quot;TX FAILED EVENT&amp;quot;);
            break;
        case NRF_ESB_EVENT_RX_RECEIVED:
            NRF_LOG_DEBUG(&amp;quot;RX RECEIVED EVENT&amp;quot;);
            if (nrf_esb_read_rx_payload(&amp;amp;rx_payload) == NRF_SUCCESS)
            {
							for (int i=0; i&amp;lt;32; i++)
							{
								m_tx_buf[i] = rx_payload.data[i];
							}
							
							// Reset rx buffer and transfer done flag
							memset(m_rx_buf, 0, m_length);
							spi_xfer_done = false;
							m_tx_buf[31]=k++;
							APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, m_length));

							while (!spi_xfer_done)
							{
									__WFE();
							}

							NRF_LOG_FLUSH();
             }
						
				     break;		
    }

}

void clocks_start( void )
{
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
}


uint32_t esb_init( void )
{
    uint32_t err_code;
    uint8_t base_addr_0[4] = {0xE7, 0xE7, 0xE7, 0xE7};
    uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2};
    uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };
    nrf_esb_config_t nrf_esb_config         = NRF_ESB_DEFAULT_CONFIG;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS_BLE;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;
    nrf_esb_config.selective_auto_ack       = false;

    err_code = nrf_esb_init(&amp;amp;nrf_esb_config);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_0(base_addr_0);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_1(base_addr_1);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_prefixes(addr_prefix, 8);
    VERIFY_SUCCESS(err_code);

    return err_code;
}

/******** NRF ESB RX ends *********/


int main(void)
{
    uint32_t err_code;
  
   	bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
	
	  clocks_start();


    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(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));
    NRF_LOG_INFO(&amp;quot;SPI example started.&amp;quot;);

	
	  err_code = esb_init();
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEBUG(&amp;quot;Enhanced ShockBurst Receiver Example started.&amp;quot;);

    err_code = nrf_esb_start_rx();
    APP_ERROR_CHECK(err_code);
		
    while (1)
    {

    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/288956?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2021 14:20:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1706179-3f99-4e23-ac83-3cfee0597c74</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think the first step would be to probe the SCK, MISO, MOSI, and CS line and check if everything looks correct. This means that the clock is sent correctly, the CS line asserted during the transaction, and the data being sent on MOSI and MISO is correct. You can use either a logical analyzer or a oscilloscope to verify this. It would be great if you could also upload an snapshot of the trace.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/288645?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2021 13:03:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04028ad6-123e-4050-ac0c-8bc61b32bc11</guid><dc:creator>Masoumeh</dc:creator><description>&lt;p&gt;I know that, but it will takes time to order nRF52840 and get it. Also, a STM micro is somehow necessary in my work.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Receiving Data with BLE and sending them with SPI to a microcontroller, which is used to send data to PC by USB connecti</title><link>https://devzone.nordicsemi.com/thread/288643?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2021 12:58:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b489351c-0889-4a4b-98d4-fa9c8e6c8ef9</guid><dc:creator>abdelali</dc:creator><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;What if you used the &lt;strong&gt;nRF52840&lt;/strong&gt; instead of the STM&lt;strong&gt;32+nRF52832&lt;/strong&gt; ?&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;nRF52840&lt;/strong&gt; has the USB peripheral, and you got libraries for handling common USB classes like CDCM, HID ...&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>