<?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>how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39903/how-to-drive-spi-cs-line-low-for-32-bits</link><description>Hi, 
 
 Can you please direct me to the document that explains about generating more than 8 bits of clock in SPI and keeping CS line low for that entire period. 
 Also, if i have to send two 16bit data, would i have to send them in lots of 8bit ? or i</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Feb 2019 08:48:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39903/how-to-drive-spi-cs-line-low-for-32-bits" /><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/169233?ContentTypeID=1</link><pubDate>Mon, 04 Feb 2019 08:48:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:670e43a9-22ca-4758-a2c6-5cb002bed3d3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there anything going out on the SPI lines when this occurs?&lt;/p&gt;
&lt;p&gt;When debugging, It is recommend that you keep the optimization level low, if not; the compiler will try to find patterns in your generated code and thus the &amp;quot;normal flow&amp;quot; will not be followed.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/168952?ContentTypeID=1</link><pubDate>Thu, 31 Jan 2019 21:54:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba700050-ea54-42ea-9bb2-f3c65cb828bb</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The problems were endianess and also the frequency. I had to decrease the frequency according to the peripheral. I am able to communicate with the IC now. But I am facing another problem now.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the attached code. I am placing the break point at every&amp;nbsp;nrf_drv_spi_transfer. But it is not stopping on&amp;nbsp;&amp;nbsp;2nd and last transfer. This is strange. If I change the order of transfers, the debugger will not stop at some other location. What could be causing this? Is the delay not enough to wait for the completion of previous transfer ? Is it getting stuck somewhere? Can you please have a quick look at this simple code snippet and advise. Thanks,&lt;pre class="ui-code" data-mode="c_cpp"&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;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */


static uint32_t       config_start =  0b01111000010101100011000000000000;           //0X30H
static uint32_t       cal_start =     0b01111000010101100100000000000000; 
static uint32_t       harm_start =    0b01111000010101100110000000000000;           //0X50H
static uint32_t       adj_start =     0b01111000010101100110000000000000;           //0X60H
static uint32_t       mmode0 =        0b11000010000010000011001100000000;           //0X60H
static uint32_t       test =          0b0011000010000000;
static uint16_t       urmsA =         0b1101100110000000;                           //0XBCH
static uint16_t       urmsB =         0b1101101010000000;                           //0XBCH
static uint16_t       urmsC =         0b1101101110000000;                           //0XBCH
static uint16_t       irmsA =         0b1101110110000000;                           //0XBCH
static uint16_t       irmsB =         0b1101111010000000;                           //0XBCH
static uint16_t       irmsC =         0b1101111110000000;                           //0XBCH
static uint32_t       uoffsetA =      0b00000000000000000110001100000000;           //0X60H
static uint32_t       uoffsetB =      0b00000000000000000110011100000000;           //0X60H
static uint32_t       uoffsetC =      0b00000000000000000110101100000000;           //0X60H
static uint32_t       ioffsetA =      0b00000000000000000110100000000000;           //0X60H
static uint32_t       ioffsetB =      0b00000000000000000110110000000000;           //0X60H
static uint32_t       ioffsetC =      0b00000000000000000110110000000000;           //0X60H
static uint32_t       igainA =        {0x30, 0x75, 0x62, 0x00};                     //0X60H
static uint32_t       igainA_r =      0b00110000011101010110001000000000;                   //0X60H
           //0X30H
 

static uint8_t       m_rx_buf[4];                                               /**&amp;lt; RX buffer. */
static const uint8_t  m_length = 4;                                            /**&amp;lt; Transfer length. */

/**
 * @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));
    }
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.ss_pin   = 47 ;
        spi_config.miso_pin = 43;
        spi_config.mosi_pin = 46;
        spi_config.sck_pin  = 42;
        spi_config.mode = NRF_DRV_SPI_MODE_0;
        spi_config.frequency = NRF_DRV_SPI_FREQ_1M;
        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;);


                       

        while(1){
      
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;config_start, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);  

          memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;cal_start, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);

         memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;harm_start, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);

         memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;adj_start, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);

         memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;igainA_r, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);

        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;irmsA, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(0);
        nrf_delay_ms(200);
    
}
}
&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/164151?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 08:00:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e57a8a08-62b1-439f-93cc-e27cad666b77</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;rx_buffer should be equal (or larger) to the length that you are receiving.&lt;/p&gt;
&lt;p&gt;Declare it like this:&lt;/p&gt;
&lt;p&gt;static uint8_t m_rx_buf[4];&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The salaea logic analyzer trace shows that your send buffer and the actual byte endianess on the bus does not correspond, as the READ bit is not set.&lt;/p&gt;
&lt;p&gt;Could you try setting your transfer buffer like this and see if the sensor responds?&lt;/p&gt;
&lt;p&gt;uint8_t&amp;nbsp;m_tx_buf4[] = {0x80, 0x30};&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/164007?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 15:24:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c94b7eb4-4938-4154-aa3e-c84b714bd644</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So my rxbuffer sjould be of 4 bytes, right? rx_buffer[4]. Is it a violation or i can directly increase the size?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Switching mode is not required as suggested by MICROCHIP. All transactions will happen using single mode only.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/163899?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 08:46:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce218081-6d6d-4978-b3bc-6b7afe7aef7b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1. You are overflowing your buffer (m_rx_buffer) by 2 bytes, as the buffer is declared as 2 byte and you are receiving 4 bytes. This is _very crucial_ that you fix.&lt;/p&gt;
&lt;p&gt;2. You are no longer switching SPI mode as per the spec for the sensor you are communicating with.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/163870?ContentTypeID=1</link><pubDate>Fri, 04 Jan 2019 03:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f089bc7-a5e9-446f-8378-febea1097862</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;I am still struggling to produce correct SPI timings . Below is the actual SPI timing sent to me by an Application Engineer from MICROCHIP. I need to replicate the same using nrf52840 chip :&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1546573430211v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am getting these SPI timings using the same operation as in above image through nrf52840 chip .&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1546573520051v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Can you identify what is going wrong with my attached firmware ????&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Any kind of help or suggestion will be appreciated . We are really running late now on our project .&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#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. */


static uint16_t       m_tx_buf4= 0b1000000000110000;    //0X30H
static uint16_t       m_tx_buf5= 0b0000000000000000;
 

static uint8_t       m_rx_buf[2];    /**&amp;lt; RX buffer. */
static const uint8_t  m_length = 4;        /**&amp;lt; Transfer length. */

/**
 * @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));
    }
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();

        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;
        spi_config.mode = NRF_DRV_SPI_MODE_0;
        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;);

        while(1){

        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;
       
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf4, m_length, m_rx_buf, m_length));
        
              while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();


        bsp_board_led_invert(3);
        nrf_delay_ms(200);  

      }
    
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Arshdeep&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/163362?ContentTypeID=1</link><pubDate>Wed, 02 Jan 2019 08:57:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4677975-2df0-4d3a-b271-16108aaa7dc8</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply.&lt;/p&gt;
&lt;p&gt;You cannot enable pull up on a gpio configured as output. If you need a pull-resistor on a GPIO configured as output, you can either set the level (1 or 0), or add an external pull-resistor.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/162429?ContentTypeID=1</link><pubDate>Wed, 19 Dec 2018 08:43:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf05df31-fcdd-4697-94eb-9e50172a3f60</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I need to enable pull ups on SPI lines. Datasheet of IC recommends to use 10K pull up resistors on SPI lines . How can I enable internal pull ups on SPI lines ? I have used&amp;nbsp;&amp;nbsp;nrf_gpio_cfg_output API to enable PULL UPS by changing its definition in nrf_gpio.h like this :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;__STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_gpio_cfg(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pin_number,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_GPIO_PIN_DIR_OUTPUT,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_GPIO_PIN_INPUT_DISCONNECT,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_GPIO_PIN_PULLUP,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_GPIO_PIN_S0S1,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_GPIO_PIN_NOSENSE);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is this the right way to do so or there is any other better way also??&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2015 - 2018, 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_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. */


static uint32_t       m_tx_buf4= 0b10000000001100000000000000000000;    //0X80BC
//static uint16_t       m_tx_buf5= 0b;
 
 



static uint16_t       m_rx_buf1[2];    /**&amp;lt; RX buffer. */
static const uint8_t  m_length1 = 4;        /**&amp;lt; Transfer length. */

/**
 * @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_buf1[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf1, strlen((const char *)m_rx_buf1));
    }
}

int main(void)
{
        bsp_board_init(BSP_INIT_LEDS);

        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();



        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;
        spi_config.mode = NRF_DRV_SPI_MODE_2;

        nrf_gpio_cfg_output(SPI_SS_PIN);
        nrf_gpio_cfg_input(SPI_MISO_PIN, NRF_GPIO_PIN_PULLUP);
        nrf_gpio_cfg_output(SPI_MOSI_PIN);
        nrf_gpio_cfg_output(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;);

        memset(m_rx_buf1, 0, m_length1);
        spi_xfer_done = false;

          //Send 80H to BCH to read power factor from BCH register
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf4, m_length1, m_rx_buf1, m_length1));
          
         while (!spi_xfer_done)
        {
            __WFE();
        }

        
      
        NRF_LOG_FLUSH();
        bsp_board_led_invert(3);
        nrf_delay_ms(200);


      
      //  memset(m_rx_buf1, 0, m_length1);
      //  spi_xfer_done = false;
       // APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf5, m_length1, m_rx_buf1, m_length1));
          
      //    while (!spi_xfer_done)
      //  {
      //      __WFE();
      //  }

      //  NRF_LOG_FLUSH();
      //  bsp_board_led_invert(2);
      //  nrf_delay_ms(200);

   }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159917?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 09:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbe2f75f-4830-46f6-b52b-ea401f5faf18</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You are not waiting for the SPI transfer to be finished (missing while(!spi_xfer_done)).&lt;/p&gt;
&lt;p&gt;Since you initialize the SPI driver with a spi_handler set, this will set the driver into non-blocking mode. If you want blocking mode, set the handler to NULL when initializing the driver.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159826?ContentTypeID=1</link><pubDate>Sat, 01 Dec 2018 22:13:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5921777-f684-4ed8-9330-77f677a55841</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Hakan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately I have access to only one channel oscilloscope for now. Have ordered one with 4 channels.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have reduced the code base just to see the mode switch. I can only see a consistent 16bit clock with no delay as described in this attached picture.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code does not work as expected .&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
        nrf_drv_spi_config_t spi_config1 = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config1.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
        spi_config1.miso_pin = SPI_MISO_PIN;
        spi_config1.mosi_pin = SPI_MOSI_PIN;
        spi_config1.sck_pin  = SPI_SCK_PIN;
        spi_config1.mode = NRF_DRV_SPI_MODE_2;
     //   APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler1, NULL));

        nrf_drv_spi_config_t spi_config2 = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config2.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
        spi_config2.miso_pin = SPI_MISO_PIN;
        spi_config2.mosi_pin = SPI_MOSI_PIN;
        spi_config2.sck_pin  = SPI_SCK_PIN;
        spi_config2.mode = NRF_DRV_SPI_MODE_3;
     //   APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler1, NULL));

       nrf_gpio_cfg_output(29);

    NRF_LOG_INFO(&amp;quot;SPI example started.&amp;quot;);



  
        while(1){

        //initialize with spi config 1
      
        APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config1, spi_event_handler, NULL));
        

        memset(m_rx_buf1, 0, m_length1);
        spi_xfer_done = false;
        //clear CS line
        nrf_gpio_pin_clear(29);
        //Send 80H to BCH to read power factor from BCH register
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf4, m_length1, m_rx_buf1, m_length1));
        NRF_LOG_FLUSH();
        bsp_board_led_invert(3);
       nrf_delay_ms(200);

        nrf_drv_spi_uninit(&amp;amp;spi);
        APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config2, spi_event_handler, NULL));
          memset(m_rx_buf1, 0, m_length1);
        spi_xfer_done = false;
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf5, m_length1, m_rx_buf1, m_length1));
        NRF_LOG_FLUSH();
        bsp_board_led_invert(2);
        nrf_delay_ms(200);

        //set CS pin high again
        nrf_gpio_pin_set(29);
         
          nrf_drv_spi_uninit(&amp;amp;spi);


        

        }


        
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1543702304462v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1543702361201v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159515?ContentTypeID=1</link><pubDate>Thu, 29 Nov 2018 09:45:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c36c2fc4-8076-44af-82b8-ae09c1ba3153</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;This looks like only one part of the SPI communication, the first 16 bits, where you lack the mode switch over to the last 16 bit transfer. Do you have access to a logic analyzer/oscilloscope with 4 channels, so that you can sample all lines simultaneously?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159273?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 15:00:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb0f4842-486e-4e58-91b4-59aad74d6dd8</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;MISO LINE&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543330745310v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;CS LINE&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543330782418v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;SCK LINE&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543330807319v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;MOSI LINE&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543330829997v4.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159200?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 11:13:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6d7b118-e747-4e9e-b826-17b5df198a42</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you able to scope all SPI lines, so that we&amp;#39;re able to see that the mode is successfully changed when reading the response from the device?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/159136?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 03:53:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:511ae214-e5b3-4bb9-a25a-5a957187a1f7</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi, I talked to the manufacturer. He asked me to check the SPI timings by doing a simple read operation on register 0x30 . I should be reading 0x6886 but i am reading 0Xffff instead. May be because of the pull up resistors on SPI pins ???&lt;/p&gt;
&lt;p&gt;It is a very small code base . I will be glad if you could verify for me if the code is right &lt;pre class="ui-code" data-mode="c_cpp"&gt;
#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. */


static uint16_t       m_tx_buf4= 0b1000000000110000;    //0X80BC
static uint16_t       m_tx_buf5= 0b0000000000000000;
 
 



static uint16_t       m_rx_buf1[1];    /**&amp;lt; RX buffer. */
static const uint8_t  m_length1 = 2;        /**&amp;lt; Transfer length. */

/**
 * @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_buf1[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf1, strlen((const char *)m_rx_buf1));
    }
}

int main(void)
{
    bsp_board_init(BSP_INIT_LEDS);

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();



        nrf_drv_spi_config_t spi_config1 = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config1.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
        spi_config1.miso_pin = SPI_MISO_PIN;
        spi_config1.mosi_pin = SPI_MOSI_PIN;
        spi_config1.sck_pin  = SPI_SCK_PIN;
        spi_config1.mode = NRF_DRV_SPI_MODE_2;
     //   APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler1, NULL));

        nrf_drv_spi_config_t spi_config2 = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config2.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
        spi_config2.miso_pin = SPI_MISO_PIN;
        spi_config2.mosi_pin = SPI_MOSI_PIN;
        spi_config2.sck_pin  = SPI_SCK_PIN;
        spi_config2.mode = NRF_DRV_SPI_MODE_3;
     //   APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler1, NULL));

       nrf_gpio_cfg_output(29);

    NRF_LOG_INFO(&amp;quot;SPI example started.&amp;quot;);



  
        while(1){

        //initialize with spi config 1
      
        APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config1, spi_event_handler, NULL));
        

        memset(m_rx_buf1, 0, m_length1);
        spi_xfer_done = false;
        //clear CS line
        nrf_gpio_pin_clear(29);
        //Send 80H to BCH to read power factor from BCH register
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf4, m_length1, m_rx_buf1, m_length1));
        NRF_LOG_FLUSH();
        bsp_board_led_invert(3);
        nrf_delay_ms(200);

        nrf_drv_spi_uninit(&amp;amp;spi);
        APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config2, spi_event_handler, NULL));
          memset(m_rx_buf1, 0, m_length1);
        spi_xfer_done = false;
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf5, m_length1, m_rx_buf1, m_length1));
        NRF_LOG_FLUSH();
        bsp_board_led_invert(2);
        nrf_delay_ms(200);

        //set CS pin high again
        nrf_gpio_pin_set(29);
         
          nrf_drv_spi_uninit(&amp;amp;spi);


        

        }


        
}
&lt;/pre&gt;or not .&lt;/p&gt;
&lt;p&gt;I am also attaching the O&amp;#39;scope diagrams of CLK and MOSI line .&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543290670591v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543290694888v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543290719607v3.png" alt=" " /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5277.Atmel_2D00_46004_2D00_SE_2D00_M90E36A_2D00_Datasheet.pdf"&gt;devzone.nordicsemi.com/.../5277.Atmel_2D00_46004_2D00_SE_2D00_M90E36A_2D00_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/158115?ContentTypeID=1</link><pubDate>Tue, 20 Nov 2018 08:29:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5197251-5472-4fb0-89e8-eebb45cc6c2f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;If GPIO 29 is your CSN, then it looks to be handled correctly. The delay calls are redundant, and can be removed.&lt;/p&gt;
&lt;p&gt;Are you able to communicate with the device? How does the scoped signals look?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/158030?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 15:31:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8bdcbe4-8b09-4ed8-a2c4-0b6afbe44b7c</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;is this the correct implementation ?&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_drv_spi_uninit(&amp;amp;spi);

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED;
spi_config.miso_pin = SPI_MISO_PIN;
spi_config.mosi_pin = SPI_MOSI_PIN;
spi_config.sck_pin = SPI_SCK_PIN;
spi_config.mode = NRF_DRV_SPI_MODE_2;
APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));

nrf_gpio_cfg_output(29);
nrf_gpio_pin_clear(29);

memset(m_rx_buf, 0, m_length);
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf4, m_length1, m_rx_buf, m_length1));
NRF_LOG_FLUSH();
bsp_board_led_invert(3);
// nrf_gpio_pin_set(BSP_BOARD_LED_0);
nrf_delay_ms(200);

nrf_drv_spi_uninit(&amp;amp;spi);

nrf_drv_spi_config_t spi_config1 = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED;
spi_config.miso_pin = SPI_MISO_PIN;
spi_config.mosi_pin = SPI_MOSI_PIN;
spi_config.sck_pin = SPI_SCK_PIN;
spi_config.mode = NRF_DRV_SPI_MODE_3;
APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config1, spi_event_handler, NULL));


nrf_gpio_pin_clear(29);

memset(m_rx_buf, 0, m_length);
spi_xfer_done = false;
APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, &amp;amp;m_tx_buf5, m_length1, m_rx_buf, m_length1));
NRF_LOG_FLUSH();
bsp_board_led_invert(3);
// nrf_gpio_pin_set(BSP_BOARD_LED_0);
nrf_delay_ms(200);

nrf_gpio_pin_set(29);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/158001?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 14:25:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5611382e-5a8b-478a-9949-ea6614a4ed2c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &amp;quot;nrf_drv_spi_transfer&amp;quot; function will set the CSN active prior to the first byte written. If you require the CSN pin to be kept low (ie: active), then you need to manually control the GPIO. This is done by setting &amp;quot;&lt;span&gt;spi_config.&lt;/span&gt;&lt;span&gt;ss_pin =&amp;nbsp;&lt;/span&gt;NRF_DRV_SPI_PIN_NOT_USED&amp;quot;, then controlling it manually in your own transfer function.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157850?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 00:19:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d2b26ab-4a9f-4953-a838-00ca22d036f5</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Thanks Einar for the explanation,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Is this the correct implementation to achieve what you showed in the diagram above ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; nrf_drv_spi_transfer (spi, first 16bit data, 2, first 16bit data, 2);&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; unint spi&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; spi mode-&amp;gt; 3&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;nrf_drv_spi_transfer (spi, last 16bit data, 2, last 16bit data, 2);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;I am just confused with the length parameter. if I am specifying 2 bytes of length, will that mean that the CS line will go high after writing 2 bytes ? if that is true, then this implementation will obviously not work.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157670?ContentTypeID=1</link><pubDate>Fri, 16 Nov 2018 09:19:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fcccbbc-1e5f-4fbc-a4f9-2cb89a6d33e3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You cannot switch mode just like that. However, I would assume that the slave device would not matter that there is a delay between the first 16 and last 16 bits, as the clock is anyway generated by the master. The idea is that after transmitting the first 16 bits you initialize the driver to use another mode and receives the 16 bits. It would stretch the transaction so that it looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/500x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-8a8176d3054444dfbdd7a0ff47b5c56e/DDB28BBE.PNG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157573?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 15:42:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dba17cf4-1745-4e99-8feb-3c02c923e7e2</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, I got that one but I am not sure where to start uninitializing and re-initialize the SPI with new configuration. If you see the attached read sequence. I have to&amp;nbsp;write first 16bits in mode 2 and then receive 16bits in SPI mode 3.&amp;nbsp;And it should not be 2 different 16 bits transaction , instead one 32 bits transaction. How can I achieve this ?&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1542296522731v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157439?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 09:29:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a085ec39-3348-447c-add4-abc2c437c3a5</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;To reinitialize you have to uninitialize the driver using nrf_drv_spi_uninit() then initialize it again with&amp;nbsp;&lt;span&gt;nrf_drv_spi_init() with the new configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Br,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Einar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157359?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 17:02:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74570308-8b89-4e84-b030-46a84a82253e</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;How can I achieve this ? I want to have a 32 bit transaction but first 16bits should be on SPI mode 2 and other 16bits on SPI mode 3. How do I uninitialize and reinitialize in between the transaction ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157338?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 14:38:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:baef0154-26e7-4084-a3bb-f83b6542fc4c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, it seems like it uses both SPI mode 2 and 3. Essentially that means that you have to uninit and reinitialize the SPI driver with a new configuration every time you switch between read and write. I would expect that to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/157189?ContentTypeID=1</link><pubDate>Wed, 14 Nov 2018 02:20:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f5801c4-086a-4cc9-906b-47a4cbb22a0d</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;One more trace of when I send 0X00305678 / 0b00000000001100000101011001111000&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/mosi.jpg" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/clk.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to drive spi CS line low for 32 bits.</title><link>https://devzone.nordicsemi.com/thread/156966?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 22:14:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e573f77-6ffa-4005-ad25-6b7fac62b547</guid><dc:creator>arshdeep</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for helping me with this. PFA the datasheet and an image where you can read about the modes. I assume, it says the data will be shifted on SDI using SPI mode 2 and on SDO using SPI mode 3. isn&amp;#39;t that right? So once I write the data on SDI line, would i have to uninitialize the SPI first to configure it to mode 3 or can i directly change the mode ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, find attached the trace of SCK and MOSI SPI lines.&lt;/p&gt;
&lt;p&gt;Can you figure out whats going wrong?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Appreciate it!!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Atmel_2D00_46004_2D00_SE_2D00_M90E36A_2D00_Datasheet.pdf"&gt;devzone.nordicsemi.com/.../Atmel_2D00_46004_2D00_SE_2D00_M90E36A_2D00_Datasheet.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1542060429673v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/SPI_5F00_MOSI.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>