<?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>The nrfx_spim driver toggles random pin when chip select pin of the driver is not used.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39145/the-nrfx_spim-driver-toggles-random-pin-when-chip-select-pin-of-the-driver-is-not-used</link><description>The nrfx_spim driver has an issue when chip select pin of the driver is not used. 
 When nrfx_spim_init is called with a nrfx_spim_config_t whose ss_pin is set to NRFX_SPIM_PIN_NOT_USED the value is not assigned to the ss_pin of the spim_control_block_t</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Oct 2018 12:48:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39145/the-nrfx_spim-driver-toggles-random-pin-when-chip-select-pin-of-the-driver-is-not-used" /><item><title>RE: The nrfx_spim driver toggles random pin when chip select pin of the driver is not used.</title><link>https://devzone.nordicsemi.com/thread/151668?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 12:48:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eefe7ce1-616d-4bfb-bc21-56860b885d5b</guid><dc:creator>Gunnar Sigur&amp;#240;sson</dc:creator><description>&lt;p&gt;Ok, I&amp;#39;ve checked the driver in sdk 15.2 and it works as you&amp;#39;ve noted.&lt;/p&gt;
&lt;p&gt;I tested it on sdk 15.0 and missed this assignment when reviewing sdk 15.2.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The nrfx_spim driver toggles random pin when chip select pin of the driver is not used.</title><link>https://devzone.nordicsemi.com/thread/151658?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 12:23:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fb2fa4e-a90d-4783-9f56-2f3e98b18f0d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;This seems to be the same issue as the one reported here:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/33246/sdk-15-spi-driver-sttting-with-ss_pin-nrf_drv_spi_pin_not_used"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/33246/sdk-15-spi-driver-sttting-with-ss_pin-nrf_drv_spi_pin_not_used&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, I believe they have fixed it in SDK 15.2.0 where they have added these lines in nrfx_spim_init():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
// &amp;#39;p_cb-&amp;gt;ss_pin&amp;#39; variable is used during transfers to check if SS pin should be toggled,
// so this field needs to be initialized even if the pin is not used.
p_cb-&amp;gt;ss_pin = p_config-&amp;gt;ss_pin;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;p_cb is a pointer to m_cb so the ss_pin is set no matter what.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The nrfx_spim driver toggles random pin when chip select pin of the driver is not used.</title><link>https://devzone.nordicsemi.com/thread/151648?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 11:37:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:534a31bf-ea29-4057-be97-d1299de3cfbb</guid><dc:creator>Gunnar Sigur&amp;#240;sson</dc:creator><description>&lt;p&gt;In the&amp;nbsp;nrfx_spim_init() function the ss_pin of the driver instance in the m_cb array is set if the ss_pin in the config is not NRFX_SPIM_PIN_NOT_USED. If however the p_config-&amp;gt;ss_pin is NRFX_SPIM_PIN_NOT_USED the ss_pin of the driver (m_cb[p_instance-&amp;gt;drv_inst_idx].ss_pin) instance is not set. The&amp;nbsp;relevant if clause is included below, it starts&amp;nbsp;at line 281 in the driver code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (p_config-&amp;gt;ss_pin != NRFX_SPIM_PIN_NOT_USED)
    {
        if (p_config-&amp;gt;ss_active_high)
        {
            nrf_gpio_pin_clear(p_config-&amp;gt;ss_pin);
        }
        else
        {
            nrf_gpio_pin_set(p_config-&amp;gt;ss_pin);
        }
        //nrf_gpio_cfg_output(p_config-&amp;gt;ss_pin);
			 nrf_gpio_cfg(p_config-&amp;gt;ss_pin,
				  NRF_GPIO_PIN_DIR_OUTPUT,
				  NRF_GPIO_PIN_INPUT_DISCONNECT,
				  NRF_GPIO_PIN_NOPULL,
				  NRF_GPIO_PIN_H0H1,
				  NRF_GPIO_PIN_NOSENSE);
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED)
        if (p_config-&amp;gt;use_hw_ss)
        {
            m_cb[p_instance-&amp;gt;drv_inst_idx].use_hw_ss = p_config-&amp;gt;use_hw_ss;
            nrf_spim_csn_configure(p_spim,
                                   p_config-&amp;gt;ss_pin,
                                   (p_config-&amp;gt;ss_active_high == true ?
                                        NRF_SPIM_CSN_POL_HIGH : NRF_SPIM_CSN_POL_LOW),
                                   p_config-&amp;gt;ss_duration);
        }
#endif
        m_cb[p_instance-&amp;gt;drv_inst_idx].ss_pin = p_config-&amp;gt;ss_pin;
        m_cb[p_instance-&amp;gt;drv_inst_idx].ss_active_high = p_config-&amp;gt;ss_active_high;
    } &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When&amp;nbsp;&lt;span&gt;nrfx_spim_xfer() is called,&lt;/span&gt;&amp;nbsp;after initializing the spim driver with ss_pin ==NRFX_SPIM_PIN_NOT_USED in the config, the ss_pin of the driver has not been initialized. In the code below p_cb-&amp;gt;ss_pin is therefore not&amp;nbsp;&lt;span&gt;NRFX_SPIM_PIN_NOT_USED and the code in the if cluase is executed. I am not using the extended mode so the use_hw_ss flag is&amp;nbsp;not checked.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    if (p_cb-&amp;gt;ss_pin != NRFX_SPIM_PIN_NOT_USED)
    {
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED)
        if (!p_cb-&amp;gt;use_hw_ss)
#endif
        {
            if (p_cb-&amp;gt;ss_active_high)
            {
                nrf_gpio_pin_set(p_cb-&amp;gt;ss_pin);
            }
            else
            {
                nrf_gpio_pin_clear(p_cb-&amp;gt;ss_pin);
            }
        }
    }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The nrfx_spim driver toggles random pin when chip select pin of the driver is not used.</title><link>https://devzone.nordicsemi.com/thread/151637?ContentTypeID=1</link><pubDate>Thu, 04 Oct 2018 11:16:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ca852cc-8bb7-4f24-89cc-72966306131d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you upload some project files that I can use to recreate this? Or point me to exactly where in the driver the ss pin is being toggled?&lt;/p&gt;
&lt;p&gt;When I test this with the basic SPI example in SDK 15.2.0 the&amp;nbsp;p_cb-&amp;gt;ss_pin is set to 0xFF (NRFX_SPIM_PIN_NOT_USED) inside&amp;nbsp;nrfx_spim_init(). Then there is an if-statement inside&amp;nbsp;nrfx_spim_xfer() that checks this and skips the toggling of the ss_pin if it is not used:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if (p_cb-&amp;gt;ss_pin != NRFX_SPIM_PIN_NOT_USED)
{
#if NRFX_CHECK(NRFX_SPIM_EXTENDED_ENABLED)
    if (!p_cb-&amp;gt;use_hw_ss)
#endif
    {
        if (p_cb-&amp;gt;ss_active_high)
        {
            nrf_gpio_pin_set(p_cb-&amp;gt;ss_pin);
        }
        else
        {
            nrf_gpio_pin_clear(p_cb-&amp;gt;ss_pin);
        }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>