<?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] not device ready</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112514/spi-not-device-ready</link><description>Hi there, 
 
 SPI device is not ready. 
 What&amp;#39;s wrong? 
 NCS version: v2.6.1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Jul 2024 08:40:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112514/spi-not-device-ready" /><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/492189?ContentTypeID=1</link><pubDate>Thu, 04 Jul 2024 08:40:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:924a3242-6808-4550-8e64-bfc2a714fceb</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I had another look at our application. Instead of running with 2x buffers, could you try the implementation we did on SPI lesson on &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-5-serial-peripheral-interface-spi/topic/exercise-1-10/"&gt;devacademy&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For some reason it looks like you are getting a &amp;quot;1&amp;quot; on the MOSI line after sending the register address&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491932?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2024 21:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38f8acc4-d204-4145-88a4-030c8c68ab29</guid><dc:creator>Robotics Gun</dc:creator><description>&lt;p&gt;As you mentioned, GPIO HIGH level Voltage&amp;nbsp;of SPI Pins are &lt;br /&gt;nRF52-DK: 3.15V &lt;br /&gt;STM F301RB: 3.59V&lt;br /&gt;&lt;br /&gt;Hmm interesting. Do you think this can cause the issue?&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1719955577948v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491835?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2024 12:28:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a8f2d35-da39-4615-9144-a358a613033f</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Thank you. What is the gpio voltage you are running? I just noticed that it was lower then the STM you compared it to.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491744?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2024 07:41:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba5e7ce6-064d-4c79-a49e-190a878d3f34</guid><dc:creator>Robotics Gun</dc:creator><description>&lt;p&gt;I followed your instruction to use zephyr official driver for icm-42688.&lt;/p&gt;
&lt;p&gt;Setting up the soft-reset and clear reset flag done successfully.&lt;/p&gt;
&lt;p&gt;Especially reading the reset flag is done through MISO pin and it&amp;#39;s done properly.&lt;/p&gt;
&lt;p&gt;Hmm. Very interesting. I hope I am making a silly mistake but I can&amp;#39;t figure it out. Please help&amp;nbsp;&lt;span&gt;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f643.svg" title="Upside down"&gt;&amp;#x1f643;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&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/pastedimage1719906016795v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;0
#include &amp;lt;zephyr/drivers/spi.h&amp;gt;
#include &amp;lt;zephyr/sys/util.h&amp;gt;
#include &amp;lt;zephyr/drivers/sensor.h&amp;gt; // sensor driver

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 1000
#define ICM42688P_SPI_NODE DT_NODELABEL(icm42688)
#define ICM42670P_SPI_CS_DT_SPEC SPI_CS_GPIOS_DT_SPEC_GET(DT_NODELABEL(reg_icm42688))

int main(void)
{
	printk(&amp;quot;sensor: Hello.\n&amp;quot;);

	const struct device *spi_dev = DEVICE_DT_GET(ICM42688P_SPI_NODE);
	const struct gpio_dt_spec spim_cs_gpio = ICM42670P_SPI_CS_DT_SPEC;
	if (!device_is_ready(spi_dev))
	{
		printk(&amp;quot;sensor: device not ready.\n&amp;quot;);
		return 0;
	}
	else
	{
		printk(&amp;quot;sensor: device ready.\n&amp;quot;);
	}

	// while (true)
	// {

	// 	k_sleep(K_MSEC(1000));
	// }

	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&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/3_2D00_zephyr-driver.jpg" /&gt;&lt;/p&gt;
&lt;p&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/4_2D00_sensor_5F00_capture.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491632?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 13:55:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01629b8e-fefd-4c12-b111-fe2642051b67</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Ah that maks more sense. I would recommend that you change your application to use the&amp;nbsp;&lt;span&gt;ICM42688&amp;nbsp; while you test now. So that the correct driver is enabled. If you switch to&amp;nbsp;ICM42688&amp;nbsp; in your application, do you see any difference in the result?&amp;nbsp;&lt;br /&gt;I will need to ask a colleage regarding the MOSI high until next byte&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Runar&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491549?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 09:57:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77c94230-6070-4b0b-b857-a78ddcf017e2</guid><dc:creator>Robotics Gun</dc:creator><description>&lt;p&gt;Sorry. I didn&amp;#39;t mentioned that I used ICM42688 for testing before PCB arrive.&lt;br /&gt;So it&amp;#39;s WHO AM I register value should be 0x47.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When you see the waveform from STM32 MOSI line(=Green Colored) stay HIGH until next byte clock starts. Is it possible to have it in nRF?&lt;br /&gt;&lt;br /&gt;If yes, how to?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491531?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 09:08:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebdce1fc-ff8e-4838-b337-184de38490cc</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I had a look in the datasheet. Are you sure you are using the&amp;nbsp;&lt;span dir="ltr"&gt;ICM42670? I would expect whoami to be 0x67 according to both the driver and the datasheet.&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/sensor/tdk/icm42670/icm42670_reg.h#L259"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/sensor/tdk/icm42670/icm42670_reg.h#L259&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span dir="ltr"&gt;Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span dir="ltr"&gt;Runar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491470?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2024 05:13:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcd7fd9a-b82c-4ac9-9476-f92999433196</guid><dc:creator>Robotics Gun</dc:creator><description>&lt;p&gt;I solved the issue with nRF SPI master/slave example.&lt;/p&gt;
&lt;p&gt;But I faced another issue.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I am using a sensor with its WHO AM I register value is 0x47.&lt;/p&gt;
&lt;p&gt;However, I keep receiving data from it 0x4C.&lt;/p&gt;
&lt;p&gt;To verify that the sensor unit has no issue, I tested with STM32.&lt;/p&gt;
&lt;p&gt;Please check it below oscilloscope waveform and decode value.&lt;/p&gt;
&lt;p&gt;[STM32]: sensor response with correct value&lt;/p&gt;
&lt;p&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/3487.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;[nRF52-DK]: sensor response with wrong value&lt;/p&gt;
&lt;p&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/67053.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;So we can conclude that the sensor has no problem. I used the same jumber cables and same oscilloscope setup.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the device tree and C code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;icm42670p: &amp;amp;spi2 {
	compatible = &amp;quot;nordic,nrf-spi&amp;quot;;
	// compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 15 GPIO_ACTIVE_LOW&amp;gt;;
	overrun-character = &amp;lt;1&amp;gt;;
	reg_icm42670p: reg_icm42670p@0 {
		reg = &amp;lt;0&amp;gt;;
	};

	max-frequency = &amp;lt;DT_FREQ_M(8)&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
/**
 * The first bit of the first byte contains the Read/Write bit and indicates the Read (1) operation
 * The first bit of the first byte contains the Read/Write bit and indicates the Write (0) operation.
 */
int spi_read_register(const struct device *spi_dev, const struct spi_config *spi_cfg, uint8_t address, uint8_t *data, size_t len)
{
    uint8_t tx_buf = REG_SPI_READ_BIT | address; // Set read bit
    printk(&amp;quot;tx_buf: %x\n&amp;quot;, tx_buf);

    struct spi_buf tx_bufs = {
        .buf = &amp;amp;tx_buf,
        .len = 1,
    };

    struct spi_buf_set tx = {
        .buffers = &amp;amp;tx_bufs,
        .count = 1
    };
    
    // size determined by tx buffer size
    struct spi_buf rx_buf[2] = {
        {
            .buf = NULL,
            // .len = 1,
            .len = sizeof(tx_buf),
        },
        {
            .buf = data,
            .len = len,
        }};

    const struct spi_buf_set rx = {
        .buffers = rx_buf,
        // .count = ARRAY_SIZE(rx_buf),
        .count = 2,
        .count = 2,
    };

    int ret = spi_transceive(spi_dev, spi_cfg, &amp;amp;tx, &amp;amp;rx);
    if (ret == 0)
    {
        printk(&amp;quot;Read from address: 0x%x, received data: 0x%x\n&amp;quot;, address, *data);
    }
    else
    {
        printk(&amp;quot;SPI transceive error: %d\n&amp;quot;, ret);
    }

    return ret;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [SPI] not device ready</title><link>https://devzone.nordicsemi.com/thread/491078?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2024 11:19:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72afd3ad-1182-45d8-9d92-dc04877a277d</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you enable logging and build your application with optimized for debug and post the log?&lt;/p&gt;
&lt;p&gt;Could you also show me your overlay?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>