<?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 communicate with LSM9DS1 and SPI with nrf52840</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34307/how-to-communicate-with-lsm9ds1-and-spi-with-nrf52840</link><description>HI. 
 I had previously implemented spi communication using the STM32 chip and the LSM9DS1. 
 Now I want to implement the same functionality using nrf52840 DK. 
 But it does not work. 
 
 STM32 
 SpiHandle.Instance = SPIx; SpiHandle.Init.BaudRatePrescaler</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 May 2018 13:10:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34307/how-to-communicate-with-lsm9ds1-and-spi-with-nrf52840" /><item><title>RE: How to communicate with LSM9DS1 and SPI with nrf52840</title><link>https://devzone.nordicsemi.com/thread/131886?ContentTypeID=1</link><pubDate>Mon, 14 May 2018 13:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0a54607-db96-4620-9f49-5fd4566be9d5</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;If you look at the definition of NRF_DRV_SPI_DEFAULT_CONFIG (found on line 214 in nrf_drv_spi.h), you will see what it defines. You can use this default config for initializing the SPI, and change the settings that you want to use, like it is done in the spi example in the SDK.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you are still having trouble getting the two chips to work together, try out the different modes&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    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;   //also test modes 1, 2 and 3
    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;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>