<?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>nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83006/nrf9160-mosi-idle-state-depending-on-last-byte-sent</link><description>Hello, 
 we are currently experiencing issues with the SPI interface which we suspect is due to the behaviour of the MOSI line in idle state. We have noticed that during communication the last byte of a message decides at which level the MOSI line will</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Jan 2022 10:29:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83006/nrf9160-mosi-idle-state-depending-on-last-byte-sent" /><item><title>RE: nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/thread/347341?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 10:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23592756-7b99-4ae3-8baa-53b1836f3b67</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Maybe, you can also possible look into manipulating the nrfx_spim driver if you want it to behave in a specific way:&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/main/nrfx/drivers/src/nrfx_spim.c#L430"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/main/nrfx/drivers/src/nrfx_spim.c#L430&lt;/a&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/main/nrfx/drivers/src/nrfx_spim.c#L430"&gt;&lt;br /&gt;&lt;/a&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/main/nrfx/drivers/src/nrfx_spim.c#L502"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/main/nrfx/drivers/src/nrfx_spim.c#L502&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/thread/347198?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 14:19:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09309f57-95f0-4e7a-903e-d0fdbe7bbb0e</guid><dc:creator>Alexander Lopatin</dc:creator><description>&lt;p&gt;Thanks for the quick answer. Is it possible to use the power manager to uninitialize SPI? The other solution would unfortunately break our current driver architecture as it strongly relies on Zephyr&amp;#39;s API&amp;#39;s and device tree model. That would take substantial rework to implement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/thread/347185?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 13:52:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a85b173-9f69-4c0f-87fd-93f41dc5635a</guid><dc:creator>Kenneth</dc:creator><description>[quote user="Alexander Lopatin"] do not think that it is possible to uninitialize Zephyr&amp;#39;s SPI driver so I will probably have to uninitialize through NRFX drivers, if I understand that correctly.[/quote]
&lt;p&gt;Unfortunately you can&amp;#39;t mix zephyr spi api with low level use of nrfx_spi and/or direct spi register access no. So if you want more low level control you need to use the nrfx_spi directly, hopefully this example may be to some help:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/thread/347164?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 13:00:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f141f63d-dfaf-4553-b20d-78e16488c73d</guid><dc:creator>Alexander Lopatin</dc:creator><description>&lt;p&gt;Hey Kenneth,&lt;/p&gt;
&lt;p&gt;sorry for the late answer. We want to make sure that this is the origin of our problem. Our driver is currently running with Zephyr&amp;#39;s SPI API. I do not think that it is possible to uninitialize Zephyr&amp;#39;s SPI driver so I will probably have to uninitialize through NRFX drivers, if I understand that correctly.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried using nrfx_spim_uninit which leads to Zephyr crashing with a bus fault.&lt;/p&gt;
&lt;p&gt;I have also tried setting the registers directly. That unfortunately had no effect on the idle state of MOSI:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void spi_disable() {
    NRF_SPIM2_NS-&amp;gt;TASKS_STOP = 1;
    NRF_SPIM2_NS-&amp;gt;ENABLE = 0;
    NRF_P0_NS-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; 10);
    NRF_P0_NS-&amp;gt;OUTCLR = (1 &amp;lt;&amp;lt; 11);
}

static void spi_enable() {
    NRF_SPIM2_NS-&amp;gt;ENABLE = 7;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can you maybe help me out on how to achieve what you have discribed?&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 MOSI idle state depending on last byte sent</title><link>https://devzone.nordicsemi.com/thread/344597?ContentTypeID=1</link><pubDate>Tue, 21 Dec 2021 12:58:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04dcba4c-f986-4cdc-98f7-57569a267574</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Likely your observation is correct, as mentioned in the post by Stian in one of your links; it should not matter the logic level of the MOSI as long as there is no more CLK. If the state is important I think the best you can do is after deasserting CSN is to disable the SPIM, this should leave pins fall back to GPIO configuration (e.g. with pull if they are set as input with pull).&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>