<?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>two channels spi on nrf52</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12643/two-channels-spi-on-nrf52</link><description>Hi, i am new to embedded system.I want to use nrf52 DK as master and connected with two slaves by two spi channels? is it possible to achieve on nrf52 DK.
1&amp;gt;How to set up and configure the two spi channels? should i enable both spi1 and spi0?
2&amp;gt;if possible</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Mar 2016 07:42:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12643/two-channels-spi-on-nrf52" /><item><title>RE: two channels spi on nrf52</title><link>https://devzone.nordicsemi.com/thread/48030?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 07:42:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a111a3cd-76ea-4da4-87e4-f51110ba058b</guid><dc:creator>oliverhu</dc:creator><description>&lt;p&gt;Hi，martin， thank you very much, it works!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: two channels spi on nrf52</title><link>https://devzone.nordicsemi.com/thread/48029?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 10:36:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd69d456-de70-4d2d-9228-31a36da53a09</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If you want to use two separate instances of SPI modules:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In SDK 11 you will need to define what SPI modules you want to use in the nrf_drv_config.h file. In the SDK examples this file is located in the folder called &amp;quot;config&amp;quot; located in the example folder. In the file, scroll down until you find this line:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define SPI0_ENABLED 0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and set it to 1. Then do the same on e.g. SPI module #1:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define SPI1_ENABLED 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, in your application you will have to crate an instance, configure, and enable both SPI modules. That can be done e.g. like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define SPI0_INSTANCE  0 /**&amp;lt; First SPI instance index. */
#define SPI1_INSTANCE  1 /**&amp;lt; Second SPI instance index. */
static const nrf_drv_spi_t spi_0 = NRF_DRV_SPI_INSTANCE(SPI0_INSTANCE );  /**&amp;lt; First SPI instance. */
static const nrf_drv_spi_t spi_1 = NRF_DRV_SPI_INSTANCE(SPI1_INSTANCE );  /**&amp;lt; First SPI instance. */

nrf_drv_spi_config_t spi_config_0 = NRF_DRV_SPI_DEFAULT_CONFIG(SPI0_INSTANCE);
nrf_drv_spi_init(&amp;amp;spi_0, &amp;amp;spi_config_0, NULL);

nrf_drv_spi_config_t spi_config_1 = NRF_DRV_SPI_DEFAULT_CONFIG(SPI1_INSTANCE);
nrf_drv_spi_init(&amp;amp;spi_1, &amp;amp;spi_config_1, NULL);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Please have a look at the SPI peripheral example in the SDK for more details.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;If you want to use one SPI module, but have two SPI devices that must be connected to the same SPI bus:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Then you will simply have to implement two Slave Select pins (SS). One for device #1 and one for #2. These SS pins must be controlled in software by your application because slave select is not implemented in the SPI hardware modules.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: two channels spi on nrf52</title><link>https://devzone.nordicsemi.com/thread/48028?ContentTypeID=1</link><pubDate>Sat, 19 Mar 2016 07:36:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c927aa28-a1cd-4241-8421-5bb44a32e31e</guid><dc:creator>oliverhu</dc:creator><description>&lt;p&gt;hi wojtek, Thank you very much. since in hardware design, I have designed the chip with two separated spi buses. hence i have to use two instances of spi. i have checked the spi example,but i am still confused about how to configure two spi instances.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; nrf_drv_spi_config_t const config =
{
    #if (SPI0_ENABLED == 1)
        .sck_pin  = SPIM0_SCK_PIN,
        .mosi_pin = SPIM0_MOSI_PIN,
        .miso_pin = SPIM0_MISO_PIN,
        .ss_pin   = SPIM0_SS_PIN,
    #elif (SPI1_ENABLED == 1)
        .sck_pin  = SPIM1_SCK_PIN,
        .mosi_pin = SPIM1_MOSI_PIN,
        .miso_pin = SPIM1_MISO_PIN,
        .ss_pin   = SPIM1_SS_PIN,
    #elif (SPI2_ENABLED == 1)
        .sck_pin  = SPIM2_SCK_PIN,
        .mosi_pin = SPIM2_MOSI_PIN,
        .miso_pin = SPIM2_MISO_PIN,
        .ss_pin   = SPIM2_SS_PIN,
    #endif
    .irq_priority = APP_IRQ_PRIORITY_LOW,
    .orc          = 0xCC,
    .frequency    = NRF_DRV_SPI_FREQ_1M,
    .mode         = NRF_DRV_SPI_MODE_1,
    .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,
    .ss_pin       = NRF_DRV_SPI_PIN_NOT_USED, //added by DS - if not specified, the nrf_drv_spi_init() will set this to high, which is wrong, CS for AS3911 is active low
};
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;for this function, how to enable two spi instance and  configure two sck, mosi,miso,ss pin?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: two channels spi on nrf52</title><link>https://devzone.nordicsemi.com/thread/48027?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2016 10:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21d4d68f-3683-4d0b-b0de-6360e3190129</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;There is spi example in SDK.
It is possible to use two instances of SPI, but if you don&amp;#39;t have to do two different transmissions to each slave simultaneously, you can use one instance only and choose slave with chip select pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>