<?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>nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17310/nrf52-spi-master-with-softdevice-can-not-work</link><description>Hi,
nrf52832, softdevice:S132
My SPI master program can initialize the SD Card succefully.
But, when I put it into the examples of ble_app_uart on nRF5_SDK_11.0.0_89a8197, it can not work.
It write a data through SPI, but can not receive any ack.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Jan 2023 02:50:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17310/nrf52-spi-master-with-softdevice-can-not-work" /><item><title>RE: nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/thread/406984?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2023 02:50:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6638c6a7-8977-4501-99cd-3fc2c1f5b683</guid><dc:creator>AllenSun</dc:creator><description>&lt;p&gt;Hello, what&amp;#39;s the meaning of &amp;quot;&lt;span&gt;With the softDevice, the SPI frequency can only be set once.&lt;/span&gt;&amp;quot;? I notice you just set the SPI frequence once in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/thread/66514?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2016 07:59:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f59de211-f2d5-441d-b6c9-80c69ef725d5</guid><dc:creator>wpb3dm</dc:creator><description>&lt;p&gt;OK，I have find the problems. With the softDevice, the SPI frequency can only be set once.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/thread/66513?ContentTypeID=1</link><pubDate>Sun, 30 Oct 2016 08:22:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:331c9733-9658-42f4-b177-4a5d1be5841b</guid><dc:creator>wpb3dm</dc:creator><description>&lt;p&gt;//the code  my added is the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;//my add start -----------------------------

#define SPI_MASTER_0_ENABLE 
#define SD_CS  	30 
#define SD_MISO	28
#define SD_MOSI	27
#define SD_SCK	29

static nrf_drv_spi_t	m_spi_master = NRF_DRV_SPI_INSTANCE(0);
static volatile bool spi_xfer_done = true;  

/**
 * @brief SPI user event handler.
 * @param event
 */
void spi_event_handler(nrf_drv_spi_evt_t const * p_event)
{
	printf(&amp;quot;p_event-&amp;gt;type=%d\r\n&amp;quot;,p_event-&amp;gt;type);

    spi_xfer_done = true;
}

/**
 * @brief spi_master_init.
 * @param spi_master_instance,spi_speed
 */
static uint32_t spi_master_init(nrf_drv_spi_t * spi_master_instance)
{
    uint32_t err_code = NRF_SUCCESS;

	nrf_drv_spi_config_t spi_config =
			{
				.ss_pin = SD_CS,
				.irq_priority = APP_IRQ_PRIORITY_LOW,
				.orc = 0xFF,
				.frequency = NRF_DRV_SPI_FREQ_4M, 
				.mode = NRF_DRV_SPI_MODE_3,
				.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,
				.sck_pin = SD_SCK,
				.mosi_pin = SD_MOSI,
				.miso_pin = SD_MISO
			};

	err_code = nrf_drv_spi_init(spi_master_instance, &amp;amp;spi_config, spi_event_handler);		

    return err_code;
    
}

//SPI Write one byte data
uint8_t SPI1_WriteOneByte(uint8_t TxData)
{
    uint8_t spi_txbuf = TxData;
	
	spi_xfer_done = false;		
    uint32_t err_code = nrf_drv_spi_transfer(&amp;amp;m_spi_master, &amp;amp;spi_txbuf, 1, NULL, 0);

	//wait for the data to transfer complete.
	while(!spi_xfer_done)
	{
		__WFE();
	}
	
	printf(&amp;quot;\r\n SPI1_WriteOneByte transfer complete\r\n&amp;quot;); 	
		
	return true;

}
//my add end -----------------------------


/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();

    buttons_leds_init(&amp;amp;erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

    printf(&amp;quot;\r\nUART Start!\r\n&amp;quot;);
    err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    APP_ERROR_CHECK(err_code);

	//my add start -----------------------------
	uint8_t i;
	spi_master_init(&amp;amp;m_spi_master);		
	nrf_delay_ms(500);	
 	for(i=0;i&amp;lt;10;i++)
		SPI1_WriteOneByte(0XFF);
    //my add end -----------------------------
	
    // Enter main loop.
    for (;;)
    {
        power_manage();
    }
}


/** 
 * @}
 */
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/thread/66512?ContentTypeID=1</link><pubDate>Sun, 30 Oct 2016 08:04:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5380ea22-fec9-4f12-b37a-a489fe457b8f</guid><dc:creator>wpb3dm</dc:creator><description>&lt;p&gt;Yes,I&amp;#39;m sure. It can not enter into void spi_event_handler(nrf_drv_spi_evt_t const * p_event). The programme stop in  while (!spi_xfer_done)
{
__WFE();
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52:SPI master with softDevice can not work</title><link>https://devzone.nordicsemi.com/thread/66511?ContentTypeID=1</link><pubDate>Tue, 25 Oct 2016 13:38:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:456becd3-7d85-4eb1-85d4-0b81e739499e</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I tried adding your code to the ble_app_uart example and printed a string to UART in spi_event_handler. This seems to work fine for me. Are you sure that you do not receive any SPI events?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>