<?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>nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52046/nrf52832-spi-with-mcp2515-nrf_drv_spi_transfer-seems-to-send-properly-but-not-receiving-in-all-cases</link><description>Hi, 
 I&amp;#39;m trying to use the nrf_drv_spi.c to communicate with a BL652 + MCP2515 CAN SPI custom device. I&amp;#39;ve connected the MCP2515 to the nRF52832 (BL652 module) in the following way with SCLK = P0.25, SPI_MISO_PIN = P0.24, SPI_MOSI_PIN = P0.23 and SPI_SS_PIN</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Sep 2019 15:29:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52046/nrf52832-spi-with-mcp2515-nrf_drv_spi_transfer-seems-to-send-properly-but-not-receiving-in-all-cases" /><item><title>RE: nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/thread/209473?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 15:29:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9486bf5a-189d-4d55-95c6-249b47fb0291</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;Presently I&amp;#39;m using SES. But if I move away from it in the future, I&amp;#39;ll have to look at it. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/thread/209283?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2019 02:25:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c99e18a7-c367-4ac5-bdf6-02b9747bc303</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;If you are not usisng SES. This is a much better driver. &amp;nbsp;Works with 100s of devices and sensors. &lt;a href="https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/spi_nrf5x.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/src/spi_nrf5x.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/thread/209262?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 17:15:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c24b1aa3-f4d4-49c5-b553-5df82d892276</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;On another note I just tried your newest response with the read command being 1 byte short. That was exactly the problem for the initialization!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Much appreciated, now I can work on getting some messages flowing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/thread/209261?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 17:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8aab1a7d-d780-44b6-8b14-ee9164876471</guid><dc:creator>BendaEng</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the response. I have tried modes 0 through 3 earlier with no results. I just tried again, but the initialization still fails. Interestingly enough regardless of SPI_MODE, the response I get for mcp2515_readStatus() is always 0x92.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Good point on the reset capacitor. I&amp;#39;ll have to test that in a moment.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SPI with MCP2515: nrf_drv_spi_transfer seems to send properly, but not receiving in all cases.</title><link>https://devzone.nordicsemi.com/thread/209260?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2019 16:57:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8ebf132-6600-45aa-b2ad-1dc07c75087c</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;SPI Modes 0,0 (Mode 0) or 1,1 (Mode 3) both work on the MCP2515, but the initialisation code above has Mode 2 (&lt;em&gt;NRF_DRV_SPI_MODE_2&lt;/em&gt;). I would suggest first try changing this to&amp;nbsp;&lt;em&gt;NRF_DRV_SPI_MODE_0 or&amp;nbsp;NRF_DRV_SPI_MODE_3.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The Reset capacitor seems very large at 10uF. given that only a minimum of 2uSec reset is required, although no max is quoted; unless the VDD rise time is extremely slow it might be wise to reduce that somewhat. 100nF might be a better choice. However that&amp;#39;s unlikely to be an issue with the SPI.&lt;/p&gt;
&lt;p&gt;The read command (if Read Instruction) seems to be 1 byte short, though it&amp;#39;s not clear which command is in the code. The 3-byte transfer is &lt;em&gt;&amp;lt;instruction&amp;gt;&amp;lt;address&amp;gt;&amp;lt;response&amp;gt;&lt;/em&gt;.&amp;nbsp;If that was meant to be Read Rx Buffer, only 2 bytes &lt;em&gt;&amp;lt;instruction&amp;gt;&amp;lt;response&amp;gt;&lt;/em&gt;, then the address would not be part of the tx.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint8_t mcp2515_readRegister(const uint8_t address)
{
    uint8_t m_tx_buf[] = {MCP_READ, address};
    uint8_t m_rx_buf[3]; // not sure what MCP_READ_STATUS is: sizeof(MCP_READ_STATUS) + 1]; 
    uint8_t m_tx_length = sizeof(m_tx_buf);
    uint8_t m_rx_length = sizeof(m_rx_buf);

    memset(m_rx_buf, 0, m_rx_length);
    spi_xfer_done = false;
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&amp;amp;can_spi, m_tx_buf, m_tx_length, m_rx_buf, m_rx_length));

     while (!spi_xfer_done)
        {
            __WFE();
        }
    return m_rx_buf[2]; // was 1, require 3rd byte
}
STATIC_ASSERT(m_rx_length == 3);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>