<?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>NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85867/nrf5284-spim3-rx-buffer-empty</link><description>Hi All, 
 
 I&amp;#39;ve run into a weird issue where my SPIM rx buffer remains empty (it&amp;#39;s not even filled with garbage - just empty). Am I operating the SPI drivers properly? My process is shown below: 
 When a command comes in over Bluetooth, I have a &amp;quot;master</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Mar 2022 23:01:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85867/nrf5284-spim3-rx-buffer-empty" /><item><title>RE: NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/thread/358750?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 23:01:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1a4865b-a791-4c5c-aea5-e0f0ac16c4b3</guid><dc:creator>ryerye120</dc:creator><description>[quote userid="73165" url="~/f/nordic-q-a/85867/nrf5284-spim3-rx-buffer-empty/358589#358589"]You right click the rx_buffer and press add variable to watch. The variable will then be added to the watch window in debug mode. For example:[/quote]
&lt;p&gt;This was incredibly helpful! In the end, it was being filled up properly. It seems like the&amp;nbsp;root issue really was a faulty&amp;nbsp;MISO jumper wire. After replacing the MISO wire I could&amp;nbsp;see the rx buff being filled up. Then I was able to take the downstream bits and properly interpret them&amp;nbsp;after converting them to chars (with the&amp;nbsp;previously posted loop).&lt;br /&gt;&lt;br /&gt;Thanks for your help, Jared!&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Kindest regards,&lt;/p&gt;
&lt;p&gt;Ryan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/thread/358589?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 10:09:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74283dc0-75d4-4234-885d-162df03f1dd0</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
[quote user="ryerye120"]How do I check if the rx buffer is being filled?&lt;br /&gt;[/quote]
&lt;p&gt;You right click the rx_buffer and press add variable to watch. The variable will then be added to the watch window in debug mode. For example:&amp;nbsp;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1647511741301v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Could add the variable to the watch window and see if the 00&amp;#39;s are actually received or not.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/thread/358512?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 01:31:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2bcb882-182b-43ba-b767-45cb713e6671</guid><dc:creator>ryerye120</dc:creator><description>&lt;p&gt;Hi Jared!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Nice to see you again.&lt;br /&gt;&lt;br /&gt;The code I initialize the driver with is copied from the nrfx_spim example:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void spi_init(void)
{
    ret_code_t err_code;



    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
    spi_config.frequency      = NRF_SPIM_FREQ_1M;
    spi_config.ss_pin         = NRFX_SPIM_SS_PIN;
    spi_config.miso_pin       = NRFX_SPIM_MISO_PIN;
    spi_config.mosi_pin       = NRFX_SPIM_MOSI_PIN;
    spi_config.sck_pin        = NRFX_SPIM_SCK_PIN;
    //spi_config.dcx_pin        = NRFX_SPIM_DCX_PIN;
    spi_config.dcx_pin        = NRFX_SPIM_PIN_NOT_USED;
    spi_config.use_hw_ss      = true;
    spi_config.ss_active_high = false;
    APP_ERROR_CHECK(nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL));


    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With the default config being:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NRFX_SPIM_DEFAULT_CONFIG                             \
{                                                            \
    .sck_pin        = NRFX_SPIM_PIN_NOT_USED,                \
    .mosi_pin       = NRFX_SPIM_PIN_NOT_USED,                \
    .miso_pin       = NRFX_SPIM_PIN_NOT_USED,                \
    .ss_pin         = NRFX_SPIM_PIN_NOT_USED,                \
    .ss_active_high = false,                                 \
    .irq_priority   = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc            = 0xFF,                                  \
    .frequency      = NRF_SPIM_FREQ_4M,                      \
    .mode           = NRF_SPIM_MODE_0,                       \
    .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,          \
    NRFX_SPIM_DEFAULT_EXTENDED_CONFIG                        \
}&lt;/pre&gt;&lt;br /&gt;(note that the sck, mosi, miso, and ss pins are all overwritten in the spi_init function)&lt;br /&gt;&lt;br /&gt;As far as the breakpoint, I have placed a breakpoint at the line in the event handler and the code is getting there. How do I check if the rx buffer is being filled?&lt;br /&gt;&lt;br /&gt;EDIT:&lt;br /&gt;&lt;br /&gt;This is sad but it may have just been a faulty jumper cable on MISO. I swapped out the jumper and reverted back to a stripped down version of the code (it&amp;#39;s bassically just the nrfx_spim and spis examples now) and I&amp;#39;ve started getting partial data (still not everything ...). It seems that when I send 00, the recieve buffer just treats it as a null... In other words i&amp;#39;m hoping to send an arbitrary array of 65 bytes (values may end up being 00) so I have set up a dummy array:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// SPI transfer buffer
static uint8_t       m_tx_buf[] = {128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,1};
static uint8_t       m_rx_buf[sizeof(m_tx_buf) + 1];        // RX buffer.
static const uint8_t m_length = sizeof(m_tx_buf);        // Transfer length.
//static uint16_t      m_length = sizeof(uint8_t)*65;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With this I *just* recieved 0x80 - which is 128 in decimal. Nothing else though! So I sent the following array:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;// SPI transfer buffer
static uint8_t       m_tx_buf[] = {128,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,1};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hexdump stops at the 0&amp;#39;s...&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Is there a better way to interpret raw bytes that come in over spi? Do I need to worry about &amp;quot;00s&amp;quot; coming in over SPI? Or can I be confident that the ble_nus_data_send will send everything I want it to?&lt;br /&gt;&lt;br /&gt;I have a janky solution that guarantees everything will be sent. I iterate&amp;nbsp;over the rx_buff and convert everything to a char:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;      char buf[196];
      uint16_t size_of_buff = sizeof(char)*196;
      for (int i = 0 ; i != 65 ; i++) 
      {
        sprintf(buf + (3*i), &amp;quot;%02x &amp;quot;, spi_rx_buf[i]);
      }
      rx_buff_hex[195] = &amp;#39;\0&amp;#39;;
      while(ble_nus_data_send(&amp;amp;m_nus, (uint8_t *) buf, &amp;amp;size_of_buff, m_conn_handle) != NRF_SUCCESS);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But this takes what would be 65 raw bytes and expands it to 196 chars manually - this seems like it will slow things down...&lt;br /&gt;&lt;br /&gt;Thanks so much for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/thread/358494?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2022 17:20:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d4a6966-2700-467c-bb4a-9ed1bf7213fb</guid><dc:creator>ryerye120</dc:creator><description>&lt;p&gt;Hi Jared!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Nice to see you again.&lt;br /&gt;&lt;br /&gt;The code I initialize the driver with is copied from the nrfx_spim example:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void spi_init(void)
{
    ret_code_t err_code;



    nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
    spi_config.frequency      = NRF_SPIM_FREQ_1M;
    spi_config.ss_pin         = NRFX_SPIM_SS_PIN;
    spi_config.miso_pin       = NRFX_SPIM_MISO_PIN;
    spi_config.mosi_pin       = NRFX_SPIM_MOSI_PIN;
    spi_config.sck_pin        = NRFX_SPIM_SCK_PIN;
    //spi_config.dcx_pin        = NRFX_SPIM_DCX_PIN;
    spi_config.dcx_pin        = NRFX_SPIM_PIN_NOT_USED;
    spi_config.use_hw_ss      = true;
    spi_config.ss_active_high = false;
    APP_ERROR_CHECK(nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL));


    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With the default config being:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NRFX_SPIM_DEFAULT_CONFIG                             \
{                                                            \
    .sck_pin        = NRFX_SPIM_PIN_NOT_USED,                \
    .mosi_pin       = NRFX_SPIM_PIN_NOT_USED,                \
    .miso_pin       = NRFX_SPIM_PIN_NOT_USED,                \
    .ss_pin         = NRFX_SPIM_PIN_NOT_USED,                \
    .ss_active_high = false,                                 \
    .irq_priority   = NRFX_SPIM_DEFAULT_CONFIG_IRQ_PRIORITY, \
    .orc            = 0xFF,                                  \
    .frequency      = NRF_SPIM_FREQ_4M,                      \
    .mode           = NRF_SPIM_MODE_0,                       \
    .bit_order      = NRF_SPIM_BIT_ORDER_MSB_FIRST,          \
    NRFX_SPIM_DEFAULT_EXTENDED_CONFIG                        \
}&lt;/pre&gt;&lt;br /&gt;(note that the sck, mosi, miso, and ss pins are all overwritten in the spi_init function)&lt;br /&gt;&lt;br /&gt;As far as the breakpoint, I have placed a breakpoint at the line in the event handler and the code is getting there. How do I check if the rx buffer is being filled?&lt;br /&gt;&lt;br /&gt;EDIT:&lt;br /&gt;&lt;br /&gt;This is sad but it may have just been a faulty jumper cable on MISO. I swapped out the jumper and reverted back to a stripped down version of the code (it&amp;#39;s bassically just the nrfx_spim and spis examples now) and I&amp;#39;ve started getting partial data (still not everything ...). It seems that when I send 00, the recieve buffer just treats it as a null... In other words i&amp;#39;m hoping to send an arbitrary array of 65 bytes (values may end up being 00) so I have set up a dummy array:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// SPI transfer buffer
static uint8_t       m_tx_buf[] = {128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,1};
static uint8_t       m_rx_buf[sizeof(m_tx_buf) + 1];        // RX buffer.
static const uint8_t m_length = sizeof(m_tx_buf);        // Transfer length.
//static uint16_t      m_length = sizeof(uint8_t)*65;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With this I *just* recieved 0x80 - which is 128 in decimal. Nothing else though! So I sent the following array:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;// SPI transfer buffer
static uint8_t       m_tx_buf[] = {128,9,9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,1};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hexdump stops at the 0&amp;#39;s...&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Is there a better way to interperet raw bytes that come in over spi?&lt;br /&gt;&lt;br /&gt;Thanks so much for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF5284 SPIM3 RX buffer empty</title><link>https://devzone.nordicsemi.com/thread/358403?ContentTypeID=1</link><pubDate>Wed, 16 Mar 2022 12:00:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a390445e-b68c-433d-8783-a0acde7eed56</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi Ryan.&lt;/p&gt;
&lt;p&gt;Could you:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;Post the code where you initialize the peripheral?&lt;/li&gt;
&lt;li&gt;Use the &lt;a href="https://www.youtube.com/watch?v=uP8RYgYGRvI"&gt;debugger &lt;/a&gt;and set a breakpoint in the handler, and check if the RX buffer is actually filled.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>