<?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 with MPU9250/6000, Issue with SPI mode 3, SDK 2.4, toolchain 2.4, Zephyr 3.2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105069/spi-with-mpu9250-6000-issue-with-spi-mode-3-sdk-2-4-toolchain-2-4-zephyr-3-2</link><description>Hello, I have passed a fair amount of time doing research on how to use SPI for SDK V2.3/2.4, I manage to get somewhere using this example git project and this other example As of now, I am doing a bare-bones code to test spi with the mpu9250 to read</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 Nov 2023 15:46:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105069/spi-with-mpu9250-6000-issue-with-spi-mode-3-sdk-2-4-toolchain-2-4-zephyr-3-2" /><item><title>RE: SPI with MPU9250/6000, Issue with SPI mode 3, SDK 2.4, toolchain 2.4, Zephyr 3.2</title><link>https://devzone.nordicsemi.com/thread/453558?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 15:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6c7e9b8-6d3c-481a-8353-6d87bd73fca0</guid><dc:creator>Mathias_Aavaa</dc:creator><description>&lt;p&gt;It was a problem with my sensor, it works great with another one,&lt;br /&gt;Have a great day&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/263a.svg" title="Relaxed"&gt;&amp;#x263a;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI with MPU9250/6000, Issue with SPI mode 3, SDK 2.4, toolchain 2.4, Zephyr 3.2</title><link>https://devzone.nordicsemi.com/thread/453484?ContentTypeID=1</link><pubDate>Wed, 01 Nov 2023 11:59:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e173bf54-a5c0-4a6f-8185-6a832b8c93da</guid><dc:creator>Kenneth</dc:creator><description>[quote user="Mathias_Aavaa"]On the other side, I expected so random answer or anything from the sensor to see it alive, but I get nothing at all.[/quote]
&lt;p&gt;Not sure if I have any suggestions, other than check that the chip is in the right mode (e.g. spi and not i2c), and that all pins are correctly (not swapped miso and mosi) and that it&amp;#39;s sufficient powered with common ground.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI with MPU9250/6000, Issue with SPI mode 3, SDK 2.4, toolchain 2.4, Zephyr 3.2</title><link>https://devzone.nordicsemi.com/thread/453382?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2023 21:01:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2315706-6411-4213-b764-cd89bb740158</guid><dc:creator>Mathias_Aavaa</dc:creator><description>&lt;p&gt;Hello Kenneth!, thank you for the links, I could not figure out how to make the zephyr one work, but the&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_spim"&gt;nrfx_spim&lt;/a&gt;&amp;nbsp;example compiled after changing the line :&amp;nbsp;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span&gt;&amp;quot;../../../common/common-pinctrl.dtsi&amp;quot;&amp;nbsp; to #include&amp;nbsp;&amp;quot;../common/common-pinctrl.dtsi&amp;quot;&lt;br /&gt;&lt;br /&gt;I then added a CS pin, a frequency&amp;nbsp;&amp;lt;1Mhz and SPI mode 3, and its seems to write the good data :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1698785414167v3.png" /&gt;&lt;br /&gt;-&amp;gt;full&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1698785392047v2.png" /&gt;&lt;br /&gt;So On the Side of the nrf5340, the spi is working as expected and writing&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;&lt;span&gt;&amp;quot;NNNordic Semiconductor&amp;quot;&lt;br /&gt;&lt;br /&gt;The clock isn&amp;#39;t&amp;nbsp;acting weird anymore, so thank you.&lt;br /&gt;&lt;br /&gt;On the other side, I expected so random answer or anything from the sensor to see it alive, but I get nothing at all.&lt;br /&gt;If you have any idea why this could be I am&amp;nbsp;&lt;/span&gt;interested, but the Spi seems to be working at least&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;So it&amp;#39;s probably on the sensor side.&lt;br /&gt;Thanks!&lt;br /&gt;main : &lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;

#include &amp;lt;nrfx_example.h&amp;gt;
#include &amp;lt;nrfx_spim.h&amp;gt;

#define NRFX_LOG_MODULE                 EXAMPLE
#define NRFX_EXAMPLE_CONFIG_LOG_ENABLED 1
#define NRFX_EXAMPLE_CONFIG_LOG_LEVEL   3
#include &amp;lt;nrfx_log.h&amp;gt;


/**
 * @defgroup nrfx_spim_blocking_example Blocking SPIM example
 * @{
 * @ingroup nrfx_spim_examples
 *
 * @brief Example showing the basic functionality of nrfx_spim driver operating in the blocking mode.
 *
 * @details Application initializes nrfx_spim driver and starts operating in the blocking mode.
 *          Specified message ( @ref MSG_TO_SEND ) from @ref m_tx_buffer is transmitted and when
 *          the transfer is finished received message is read from @ref m_rx_buffer.
 */

/** @brief Symbol specifying SPIM instance to be used. */
#define SPIM_INST_IDX 1

/** @brief Symbol specifying pin number for MOSI. */
#define MOSI_PIN LOOPBACK_PIN_1A

/** @brief Symbol specifying pin number for MISO. */
#define MISO_PIN LOOPBACK_PIN_1B

/** @brief Symbol specifying pin number for SCK. */
#define SCK_PIN LOOPBACK_PIN_2A

#define CS_PIN 25
/** @brief Symbol specifying message to be sent via SPIM data transfer. */
#define MSG_TO_SEND &amp;quot;NNNordic Semiconductor&amp;quot;

/** @brief Transmit buffer initialized with the specified message ( @ref MSG_TO_SEND ). */
static uint8_t m_tx_buffer[] = MSG_TO_SEND;


/** @brief Receive buffer defined with the size to store specified message ( @ref MSG_TO_SEND ). */
static uint8_t m_rx_buffer[sizeof(MSG_TO_SEND)];

/**
 * @brief Function for application main entry.
 *
 * @return Nothing.
 */
int main(void)
{
    nrfx_err_t status;
    (void)status;

    NRFX_EXAMPLE_LOG_INIT();

    NRFX_LOG_INFO(&amp;quot;Starting nrfx_spim basic blocking example.&amp;quot;);
    NRFX_EXAMPLE_LOG_PROCESS();

    nrfx_spim_t spim_inst = NRFX_SPIM_INSTANCE(SPIM_INST_IDX);
  

     nrfx_spim_config_t spim_config = NRFX_SPIM_DEFAULT_CONFIG(SCK_PIN,MOSI_PIN,MISO_PIN,CS_PIN);
     spim_config.frequency = 500U*1000U;
     spim_config.mode = 3;
                            
    status = nrfx_spim_init(&amp;amp;spim_inst, &amp;amp;spim_config, NULL, NULL);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    nrfx_spim_xfer_desc_t spim_xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buffer, sizeof(m_tx_buffer),m_rx_buffer, sizeof(m_rx_buffer));

    status = nrfx_spim_xfer(&amp;amp;spim_inst, &amp;amp;spim_xfer_desc, 0);
    NRFX_ASSERT(status == NRFX_SUCCESS);

    NRFX_LOG_INFO(&amp;quot;Message received: %s&amp;quot;, m_rx_buffer);

    NRFX_EXAMPLE_LOG_PROCESS();

    while (1)
    {
        NRFX_EXAMPLE_LOG_PROCESS();
    }
}
/** @} */
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SPI with MPU9250/6000, Issue with SPI mode 3, SDK 2.4, toolchain 2.4, Zephyr 3.2</title><link>https://devzone.nordicsemi.com/thread/452434?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2023 07:51:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e542585a-d14d-45b5-8895-80ce15dc7a69</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;My suggestion would be to look at existing zephyr drivers using spi, or look at the test code for the spi driver:&lt;br /&gt;\zephyr\tests\drivers\spi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t want to use the spi api, you can use the low level nrfx spim api directly:&lt;br /&gt;&lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_spim"&gt;https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_spim&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>