<?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>SPI configuration?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81658/spi-configuration</link><description>when i try to configure spi1 i am getting error, so how can i configure different spi ?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Nov 2021 14:00:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81658/spi-configuration" /><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338817?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 14:00:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a9c6b84-9939-49ca-8a92-3d3c546207e8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Ah, yes. I did not think about that. Assuming you have added the&amp;nbsp;requiered include folder etc you are lacking the PRS configuraiton in sdk_config.h. Depending on which sdk_config.h you used as a starting point there may be more like this. Please&amp;nbsp;search for&amp;nbsp;NRFX_PRS_ENABLED and&amp;nbsp;NRFX_PRS_BOX_4_ENABLED in sdk_config.h. You may need to do this with other components as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338812?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 13:46:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b263768-8e94-488b-a2be-4f4d14d928eb</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;i am getting error like this&lt;/p&gt;
&lt;p&gt;undefined reference to `nrfx_prs_acquire&amp;#39;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338803?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 13:26:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df758d79-ad91-417c-9412-2c094f1d7131</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Please refer to&amp;nbsp;example I linked to before to see an&amp;nbsp;example of sdk_config.h when using SPI. The relevant section (copy-pasted from the example) is this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;e&amp;gt; SPI_ENABLED - nrf_drv_spi - SPI/SPIM peripheral driver - legacy layer
//==========================================================
#ifndef SPI_ENABLED
#define SPI_ENABLED 1
#endif
// &amp;lt;o&amp;gt; SPI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
 

// &amp;lt;i&amp;gt; Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef SPI_DEFAULT_CONFIG_IRQ_PRIORITY
#define SPI_DEFAULT_CONFIG_IRQ_PRIORITY 6
#endif

// &amp;lt;o&amp;gt; NRF_SPI_DRV_MISO_PULLUP_CFG  - MISO PIN pull-up configuration.
 
// &amp;lt;0=&amp;gt; NRF_GPIO_PIN_NOPULL 
// &amp;lt;1=&amp;gt; NRF_GPIO_PIN_PULLDOWN 
// &amp;lt;3=&amp;gt; NRF_GPIO_PIN_PULLUP 

#ifndef NRF_SPI_DRV_MISO_PULLUP_CFG
#define NRF_SPI_DRV_MISO_PULLUP_CFG 1
#endif

// &amp;lt;e&amp;gt; SPI0_ENABLED - Enable SPI0 instance
//==========================================================
#ifndef SPI0_ENABLED
#define SPI0_ENABLED 1
#endif
// &amp;lt;q&amp;gt; SPI0_USE_EASY_DMA  - Use EasyDMA
 

#ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1
#endif

// &amp;lt;/e&amp;gt;

// &amp;lt;e&amp;gt; SPI1_ENABLED - Enable SPI1 instance
//==========================================================
#ifndef SPI1_ENABLED
#define SPI1_ENABLED 0
#endif
// &amp;lt;q&amp;gt; SPI1_USE_EASY_DMA  - Use EasyDMA
 

#ifndef SPI1_USE_EASY_DMA
#define SPI1_USE_EASY_DMA 1
#endif

// &amp;lt;/e&amp;gt;

// &amp;lt;e&amp;gt; SPI2_ENABLED - Enable SPI2 instance
//==========================================================
#ifndef SPI2_ENABLED
#define SPI2_ENABLED 0
#endif
// &amp;lt;q&amp;gt; SPI2_USE_EASY_DMA  - Use EasyDMA
 

#ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1
#endif

// &amp;lt;/e&amp;gt;

// &amp;lt;/e&amp;gt;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338797?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 13:13:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff16fd9e-7334-4136-b5b3-96c08cf48975</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;what are the functions i am suppose to enable in sdk_config file ?&lt;/p&gt;
&lt;p&gt;and i need sdk_config file&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338781?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 12:42:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87306eaf-a1e5-4ac6-ac0f-a6c70532ccb3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;To use blocking mode you do not provide a event handler when you initialize the driver using&amp;nbsp;nrf_drv_spi_init(). So in your code, you would change the call to&amp;nbsp;nrf_drv_spi_init() like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, NULL, NULL));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then call&amp;nbsp;nrf_drv_spi_transfer() like before (but fix it so that you check return values!) and the function will not return until the transaction has completed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338771?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 12:12:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab7a5713-bb03-44b5-8441-72ec1b4fcbb7</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;i need details regarding the library structure what is nrf_spi.h nrfx_drv_spi.h what are all the files i am suppose to include for spi?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338769?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 12:10:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55996a67-2b96-40df-838b-a9398e0cec05</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;How to transfer a data in blocking mode?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338761?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 11:53:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83ae60f4-dec0-4365-94d3-bd7815b4ca18</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;code was hanged here&lt;/p&gt;
&lt;p&gt;while (!nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_END))&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338756?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 11:17:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ef9b506-03b5-4cb2-9e8c-461d53047928</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I took the liberty to format your C code for improved readability.&lt;/p&gt;
&lt;p&gt;You write that the clock was not generated. That means that no SPI transaction was started, so I expect an error has occured. I notice in your code that you ignore most return values. That is a very bad idea, and the first thing you should do is to improve your code so that you check all return values using&amp;nbsp;APP_ERROR_CHECK (particularly the return values from&amp;nbsp;nrf_drv_spi_transfer()). Are there any errors here? What else do you see from debugging?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338753?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 11:02:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:300680cd-f522-4312-96f8-86736561e079</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;when i configure spi like that clock was not generated at all&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338752?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 11:01:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:705af031-a301-4318-8fdf-684bc41b4ad0</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
* DAC.c
*
* Created on: Nov 2, 2021
* Author: 91889
*/
#include &amp;quot;DAC.h&amp;quot;
#include &amp;quot;stdio.h&amp;quot;
//#include &amp;quot;main.h&amp;quot;
#include &amp;quot;nrf_drv_spi.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;lt;string.h&amp;gt;

#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;

#define SPI_SS_PIN 31
#define SPI_MISO_PIN 30
#define SPI_MOSI_PIN 29
#define SPI_SCK_PIN 26
#define CS_Pin 5

#define VREF 2500
#define MULTIPLIER (65536 / VREF)

//extern SPI_HandleTypeDef hspi1;

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));
}*/
}

void Spi0_init(void)
{
    nrf_drv_spi_config_t spi_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;
    spi_config.frequency = NRF_SPI_FREQ_4M;
    spi_config.mode = NRF_SPI_MODE_0;
    spi_config.bit_order = NRF_SPI_BIT_ORDER_MSB_FIRST;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));
}

void Dac_Input(uint8_t chanel, uint16_t value)
{
    static uint8_t m_tx_buf[] = {0};
    static uint8_t m_rx_buf[] = {0};
    static const uint8_t m_length = sizeof(m_tx_buf);
    float multipiler = (float)65536 / VREF;
    uint8_t tx_Buffer;
    uint16_t dac_Value;
    if (value == 2500)
    {
        dac_Value = 65535;
    }
    else
    {
        dac_Value = (uint16_t)(value * multipiler);
    }
    nrf_gpio_cfg_output(CS_Pin);
    nrf_gpio_pin_clear(CS_Pin);
    //HAL_GPIO_WritePin(GPIOA, CS_Pin, GPIO_PIN_RESET);
    if (chanel == channel_A)
    {
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
        m_tx_buf[0] = 0x30;
        //HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
        nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, NULL);
        //HAL_Delay(50);
        //power_down channel_B
        // tx_Buffer = 0x41;
        // HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
    }
    else
    {
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
        m_tx_buf[0] = 0x31;
        //HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
        nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, NULL);
        //HAL_Delay(50);
        //power_down channel_A
        // tx_Buffer = 0x40;
        // HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
    }
    memset(m_rx_buf, 0, m_length);
    spi_xfer_done = false;
    m_tx_buf[0] = (uint8_t)((dac_Value &amp;amp; 0xFF00) &amp;gt;&amp;gt; 8);
    //HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
    nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, NULL);
    memset(m_rx_buf, 0, m_length);
    spi_xfer_done = false;
    m_tx_buf[0] = (uint8_t)(dac_Value &amp;amp; 0x00FF);
    //HAL_SPI_Transmit(&amp;amp;hspi1, &amp;amp;tx_Buffer, 1, 100);
    nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, m_length, m_rx_buf, NULL);

    //HAL_GPIO_WritePin(GPIOA, CS_Pin, GPIO_PIN_SET);
    nrf_gpio_pin_set(CS_Pin);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338731?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 09:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c9576fa-76a9-448b-b229-3f2f3b8e5a3a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I see. I suggest you refer to the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/spi_master_example.html"&gt;SPI Master Example&lt;/a&gt; and the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/hardware_driver_spi_master.html"&gt;SPI master driver documentation&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338726?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 09:45:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3dbe614-8983-481e-bd31-5fa4f2e053f9</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;clock was not generated at all and can there be a document/ video how to configure SPI?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338724?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 09:43:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0c6b489-08cf-45a7-8279-be83dd4c0546</guid><dc:creator>venkatesha kj</dc:creator><description>&lt;p&gt;i have used sdk 17.1&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI configuration?</title><link>https://devzone.nordicsemi.com/thread/338692?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 08:07:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7625d02f-46a5-48d3-8cd1-4d3b8b61bdfa</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you explain which SDK you are using, how you configure your SPI and which error you get? Please elaborate.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>