<?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>Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32670/unable-to-interface-nrf51822-with-lis3dh-accelerometer-using-spi-being-nrf-as-master</link><description>Hi, 
 I tried interfacing LIS3Dh using SPI, I used the SPI example to start with, when I didn&amp;#39;t get the desired result, I look numerous question on the forum and tried to modify the code but it does not seem to be working. 
 I am simply trying to read</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Sep 2021 17:35:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32670/unable-to-interface-nrf51822-with-lis3dh-accelerometer-using-spi-being-nrf-as-master" /><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/327674?ContentTypeID=1</link><pubDate>Wed, 01 Sep 2021 17:35:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d05f0169-81cd-47ed-a8cd-af426c6e0ba7</guid><dc:creator>jjifa</dc:creator><description>&lt;p&gt;&lt;span&gt;I faced the same problem.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;there is a difference, only 0x00 is entered in MISO.&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Have you solved this problem?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/223435?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 20:57:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e29acd9-269a-420c-8fd5-07a7672740da</guid><dc:creator>yanchevm</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/renatomorelli"&gt;RenatoMorelli&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m also trying to create project with nrf52 + LIS3DH. Can you please attach or send me the example project ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130689?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 23:53:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fd970a6-4df5-40d8-9f3f-af703f1d3156</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Hey, &lt;a href="https://devzone.nordicsemi.com/members/agamrjain"&gt;Agam&lt;/a&gt;, try these changes on your code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t       m_tx_buf[] = {0x8F,0x00};   &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;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[1] != 0) // change the byte to compare here
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_INFO(&amp;quot; %X&amp;quot;,m_rx_buf[1]); // here to print it
//        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130688?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 23:44:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59ecb6f5-805b-4ceb-a321-7cb9423770bc</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Yep, you got it right. I was mistakenly sending, for the scopeshots, 0x87 instead of 0x8F (I even tried to delete the comment, but I couldn&amp;#39;t)&lt;/p&gt;
&lt;p&gt;Now I got it working but had to reduce the speed (as you pointed above) and to modify the loop back example to check for the second byte in the answer.&lt;/p&gt;
&lt;p&gt;Really had to use the scope for this (8MHz was inserting harmonics in my clock signal and the reverse analysis from an old code got me to try the mode 3, the one that worked).&lt;/p&gt;
&lt;p&gt;TL;DR I used mode 0 and 3 to make it work&lt;/p&gt;
&lt;p&gt;Here I share my happiness with you, thansk so much&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;MOSI&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/req_5F00_fin.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;MISO&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/ans_5F00_fin.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130685?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 23:21:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72d16578-c1fd-452c-a01e-876155456afa</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Isn&amp;#39;t that the answer? The &amp;#39;scope shows you are sensing 0x87 which agrees with the code above; Whoami requires 0x8F ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130682?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 23:14:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:427530b1-ebce-4e1a-80bc-7dcac863b1d0</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;It is weird, but I used the example from the sdk 14.2. I just modified the buffer to the register I wanted.&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;

#include &amp;quot;nrf_gpio.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. */

//sck//scl 03
//miso//sdo 28
//mosi//sda 4
//ss/cs 29 

//#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = {0x87,0x00};           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[] = {0x00,0x00};    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&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_leds_init();

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    
    NRF_LOG_INFO(&amp;quot;SPI example.&amp;quot;);

    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.frequency = NRF_SPI_FREQ_125K;
    spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
    spi_config.mode      = NRF_DRV_SPI_MODE_3;           
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));

    while (1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;

        bsp_board_led_invert(BSP_BOARD_LED_0);
        
        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();

        bsp_board_led_invert(BSP_BOARD_LED_0);
        nrf_delay_ms(1000);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130677?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 22:51:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74a67865-8209-40b3-b4b6-c343cea28a52</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The LIS3DH clocks data in on the rising clock edge; hence&amp;nbsp;last &amp;#39;scope screenshot shows a transmitted command value of 0x87 not 0x8F. The traces would be easier to read if they were vertically separated slightly .. while still overlapping. Perhaps post the function you are using to generate this trace, in case we see something there ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130665?ContentTypeID=1</link><pubDate>Wed, 02 May 2018 19:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5dc8f70-663e-47ad-973a-ddb2c1f7c736</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;I tried this, not working :/&lt;/p&gt;
&lt;p&gt;I appealed to the oscilloscope and this is my SPI bitbang that works&lt;/p&gt;
&lt;p&gt;Blue is the clock and yellow is the mosi of 0x8f (read whoami)&lt;br /&gt;&lt;img alt="mosi (y) and clock (b) of 0x8F" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/quest_5F00_OK.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Blue is the clock and yellow is the chip select&lt;/p&gt;
&lt;p&gt;&lt;img alt="Chip select (y) and clock (b)" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/cs_5F00_OK.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;------&lt;/p&gt;
&lt;p&gt;Now the part that doesn&amp;#39;t work, from the nordic sdk api call to spi.&lt;/p&gt;
&lt;p&gt;Please note that this is on MODE 0.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;pre class="ui-code" data-mode="c_cpp"&gt;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.frequency = NRF_SPI_FREQ_125K;
spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
spi_config.mode      = NRF_DRV_SPI_MODE_0; &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Blue is the clock and yellow is the mosi of 0x8f (read whoami)&lt;/p&gt;
&lt;p&gt;&lt;img alt="Clock (b) and mosi (y)" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0x8F_5F00_spi_5F00_bad.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Blue is clock and yellow is the chip select&lt;/p&gt;
&lt;p&gt;&lt;img alt="clock (b) and cs (y)" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0x8F_5F00_spi_5F00_clk.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Blue is the clock and yellow is the mosi of {0x8f,0xff} (read whoami), like &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt; suggested &lt;/p&gt;
&lt;p&gt;&lt;img alt="Clock (b) and miso (y)" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0x8F_5F00_0xFF_5F00_spi_5F00_bad.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: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130037?ContentTypeID=1</link><pubDate>Thu, 26 Apr 2018 19:35:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ff0955b-ac79-4f59-89c9-7a10803e9aad</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Ah-Ha! Try reading .. use 0x8F not 0x0F .. similar to this - or did you try that I now notice above&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    uint8_t tx_buf[] = {0x80|LIS2DH12_WHO_AM_I, 0xFF};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130034?ContentTypeID=1</link><pubDate>Thu, 26 Apr 2018 19:02:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fb17e2b-649f-435d-b6d4-20a0913b5e5a</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Sorry, my bad. I did try mode 0, which is the default one.&lt;/p&gt;
&lt;p&gt;I &lt;span&gt;slightly modified the SPI example in SDK 14.2, here how it looks like. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;0x0F is the WHO_AM_I register, and I tried too 0X8F (bit 7 high for read operation).&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I really appreciate your help, thanks &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt;. There are a few other threads about this same problem here in the devzone.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&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;

#include &amp;quot;nrf_gpio.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. */

// according to sdk_config.h
//SPI0_ENABLED 1
//SPI0_USE_EASY_DMA 1
//SPI_SCK_PIN 3
//SPI_MISO_PIN 28
//SPI_MOSI_PIN 4
//SPI_SS_PIN 29

//#define TEST_STRING &amp;quot;Nordic&amp;quot;
static uint8_t       m_tx_buf[] = {0x0F,0x00};           /**&amp;lt; TX buffer. */
static uint8_t       m_rx_buf[] = {0x00,0x00};    /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&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_leds_init();

    APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    
    NRF_LOG_INFO(&amp;quot;SPI example.&amp;quot;);

    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.frequency = NRF_SPI_FREQ_125K;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));

    while (1)
    {
        // Reset rx buffer and transfer done flag
        memset(m_rx_buf, 0, m_length);
        spi_xfer_done = false;

        bsp_board_led_invert(BSP_BOARD_LED_0);
        
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, 2, m_rx_buf, 2));

        while (!spi_xfer_done)
        {
            __WFE();
        }

        NRF_LOG_FLUSH();

        bsp_board_led_invert(BSP_BOARD_LED_0);
        nrf_delay_ms(1000);
    }
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130033?ContentTypeID=1</link><pubDate>Thu, 26 Apr 2018 18:58:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc730957-8d26-4166-a61c-aa0f57be3270</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I just noticed something: Product Spec v3.3 SPI Max frequency is listed at 4MHz; I see you are using 8MHz&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;fSCK SCK frequency. 0.125 4 MHz&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130031?ContentTypeID=1</link><pubDate>Thu, 26 Apr 2018 18:48:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d2e8027-d11d-4128-b75a-24b0be92ee2c</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;You tried modes 1,2,3 but did you try mode 0? I use mode 0 with the similar part. Maybe post your code again is case we can spot something ..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/130029?ContentTypeID=1</link><pubDate>Thu, 26 Apr 2018 18:22:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9312c26a-9e5c-469c-b56b-ca001f663268</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Ok,&amp;nbsp;MOSI and MISO, sorry for the inaccurate terminology.&lt;/p&gt;
&lt;p&gt;I managed to make the I2C (or TWI) work, but I need to do it with the SPI and the SDK functions are not working for me.&lt;/p&gt;
&lt;p&gt;I even did a bit-bang for the SPI and it worked, but I need help with the SDK SPI.&lt;/p&gt;
&lt;p&gt;I checked on the oscilloscope and CS in going low during communication window, MOSI is fine, CLK is fine, but get 0xFF on MISO when asking for WHO_AM_I. I initialized the SPI, tried modes 1 to 3, changed the data rate, enlarged the buffers (rx and tx with the same size), but I am still missing something :/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/129421?ContentTypeID=1</link><pubDate>Mon, 23 Apr 2018 22:23:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66ad5ea3-50fd-4205-82c4-0c4ab5cad380</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;There is no SDA or SDO signal on an SPI interface;&amp;nbsp;&lt;span&gt;SDA or SDO are only applicable to I2C which is a very different protocol being both more complex to implement and much slower in operation. There are examples for I2C and I2C fully supported by the Nordic libraries so perhaps search&amp;nbsp;for those. Commonly I2C is used where multiple devices exist on a single 2-wire serial bus.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/129416?ContentTypeID=1</link><pubDate>Mon, 23 Apr 2018 21:23:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80ef7e04-0f83-46bc-9c34-d888443740f1</guid><dc:creator>RenatoMorelli</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I did what you say, but I only get 0xFF :/&lt;/p&gt;
&lt;p&gt;&amp;nbsp; SPI 0 is enabled on config.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; I checked some repos on the internet and the example on sdk 14.2, but no progress. When I change SDA and SDO, I get no response at all or 0xFF.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; What could it be?&lt;/p&gt;
&lt;p&gt;Thanks :D&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/125873?ContentTypeID=1</link><pubDate>Sun, 25 Mar 2018 15:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9417add4-0791-4f98-b3a6-3baceab86e9b</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The SPI can&amp;#39;t return the id you require using your code since the LIS doesn&amp;#39;t know what the command is until after the 8-bit tx transfer is complete. If sending an 8-bit command that didn&amp;#39;t require a response then a length of 1 byte transfer is fine, but you want the ID response so therefore you require a 2-byte transfer: 1st tx byte is request, 2nd a dummy 0. 1st Rx byte a dummy, 2nd a response to the Tx command request. In general the Rx stream is always 1-byte behind the tx stream since the first tx byte instructs the LIS what to put in the response.&lt;/p&gt;
&lt;p&gt;I would stick with Mode 0 as that works .. also I would recommend finding the LIS in the examples, eg: look in Thingy SDK v2.1.0\include\frivers which can be downloaded from Nordic&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Read and verify accelerometer ID.
 */
static ret_code_t lis3dh_verify_id(void)
{
    ret_code_t  err_code;
    uint8_t     reg_val;

    err_code = lis3dh_read_regs(WHO_AM_I, &amp;amp;reg_val);
    RETURN_IF_ERROR(err_code);

    return (reg_val == I_AM_LIS3DH);
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/125867?ContentTypeID=1</link><pubDate>Sun, 25 Mar 2018 07:31:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4233b99-8394-42b1-b00d-be41dc1ede41</guid><dc:creator>Agam</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for guiding. yeah, I am implementing SPI for first time, I increased the size of tx_buff to 5, and before sending I specify the correct length&lt;pre class="ui-code" data-mode="text"&gt; uint8_t rx_length = 1;        /**&amp;lt; Transfer length. */
        uint8_t tx_length = 1;
        
        spi_xfer_done = false;
        //STATIC_ASSERT(tx_length == rx_length);
        APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, tx_length, m_rx_buf, rx_length));
        while (!spi_xfer_done){
	  __WFE();
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t m_tx_buf[]={0x0F, 0x00, 0x00, 0x00, 0x00}; /**&amp;lt; TX buffer. */
static uint8_t m_rx_buf[]={0x00, 0x00, 0x00, 0x00, 0x00}; /**&amp;lt; RX buffer. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I kept the mode=2 because in datasheet of sensor is says &amp;quot; Those lines are driven at the falling edge of SPC and should be captured at the rising edge of SPC&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Output is still FF only.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for quick reply :)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/125862?ContentTypeID=1</link><pubDate>Sun, 25 Mar 2018 05:26:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:937364fc-9886-41d9-b6d5-8a1e6936e42b</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;You have at least two problems: you might try SPI_MODE_0 instead of MODE_2, as that works correctly with the similar part LIS2DH12. Also if this is the first time you have used SPI, it&amp;#39;s not obvious that to receive (say) 5 bytes that you actually have to transmit 5 bytes as the transmit provides the clock required for the receive. In the case above only 1 byte is transmitted, so increase that to 5&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    spi_config.ss_pin    = ACC_CS_PIN;
    spi_config.miso_pin  = ACC_MISO_PIN;
    spi_config.mosi_pin  = ACC_MOSI_PIN;
    spi_config.sck_pin   = ACC_SCK_PIN;
    spi_config.frequency = NRF_SPI_FREQ_8M;
    spi_config.bit_order = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST;
    spi_config.mode      = NRF_DRV_SPI_MODE_0;
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;mAccSpiInstance, &amp;amp;spi_config, acc_spi_event_handler, NULL));

static uint8_t m_tx_buf[]={0x0F, 0x00, 0x00, 0x00, 0x00}; /**&amp;lt; TX buffer. */
static uint8_t m_rx_buf[]={0x00, 0x00, 0x00, 0x00, 0x00}; /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_rx_buf);       /**&amp;lt; Transfer length. */

// Ensure transmit and receive buffers are identical lengths
#include &amp;quot;nrf_drv_common.h&amp;quot;;
STATIC_ASSERT(sizeof(m_rx_buf) == sizeof(m_tx_buf));
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And now specify correct lengths:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Ensure transmit and receive buffers are identical lengths
#include &amp;quot;nrf_drv_common.h&amp;quot;;

// 2 bytes each or whatever ..
uint8_t sizerx = 2, sizerx = 2;

STATIC_ASSERT(sizetx == sizerx);

APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;spi, m_tx_buf, sizetx, m_rx_buf, sizerx));
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/125860?ContentTypeID=1</link><pubDate>Sun, 25 Mar 2018 03:54:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8960a66-5c6e-4a3c-a014-b35d4039f3b2</guid><dc:creator>Agam</dc:creator><description>&lt;p&gt;No, I dont have logic analyzer&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there any other way to check ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to interface nrf51822 with LIS3DH (accelerometer) using SPI being nrf as master</title><link>https://devzone.nordicsemi.com/thread/125667?ContentTypeID=1</link><pubDate>Fri, 23 Mar 2018 08:44:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ba9ced4-08f2-49cf-bdcd-54ed85176a55</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you checked the SPI bus with a logic analyzer, to see if anything is actually transmitted/received?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>