<?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>Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40622/nrf-spi-timing-configurations</link><description>Hello sir, 
 I am a beginner on NRF52840. I am using Nrfx_spim example for interfacing sensor with NRF Board. 
 I have done some driver about Reg_read and Reg_write. I tried to read the device ID of the sensor through SPI yielding improper results. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Nov 2018 12:13:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40622/nrf-spi-timing-configurations" /><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/159009?ContentTypeID=1</link><pubDate>Mon, 26 Nov 2018 12:13:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf3b4935-a52f-4ad8-af17-22375dc2ab70</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;We don&amp;#39;t have any information other than what you can find through looking in the spi chapter in product specification, spi driver documentation and the spi example in the sdk. Combining the sources of information you should be able to make the spi work with any device that supports spi serial interface.&lt;/p&gt;
&lt;p&gt;It is very rarely that anyone look into the detailed hold, setup, rise and fall times for the various signals you refer to. For instance the values you refer to are for most part minimum values in ns range, and I am sure they are not the cause to your current issues.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158933?ContentTypeID=1</link><pubDate>Sun, 25 Nov 2018 17:48:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61f503f4-307c-4be7-900e-791dfe79d15a</guid><dc:creator>rohit</dc:creator><description>&lt;p&gt;Please reply&lt;/p&gt;
&lt;p&gt;Gentle reminder....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158909?ContentTypeID=1</link><pubDate>Sat, 24 Nov 2018 13:42:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bdfc202b-dd74-4983-8901-629f2b47b4e3</guid><dc:creator>rohit</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I tested out both that drivers (SPI and SPIM) I am unable to figure out how to meet the requirement as given in below diagram.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1543066608268v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;can you please share me&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;APIs with configurations&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;which can meet above diagram.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;please share the waveforms capture by you to meet above requirement.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;a project is quite critical quick help could be highly appreciated.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is another pin named &lt;strong&gt;DCx&lt;/strong&gt; as seen from data sheet which comes under &lt;strong&gt;SPIM&lt;/strong&gt; interface. I want to work as&lt;strong&gt; legacy SPI&lt;/strong&gt; with &lt;strong&gt;MISO MOSI SCLK CS PINS, Hence&amp;nbsp;is SPIM Driver suitable for this.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Rohit&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158807?ContentTypeID=1</link><pubDate>Fri, 23 Nov 2018 11:30:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7579b6ad-3d52-4951-bad5-14645a50fa40</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You misunderstand. The problem here is your logic analyzer that can&amp;#39;t handle the SPI data stream, you must set the sample rate to higher in your &amp;quot;Hantek&amp;quot; analyzer.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158718?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 16:16:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a59cfda0-55e6-4966-82e6-4f532c10071b</guid><dc:creator>rohit</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Since&amp;nbsp; i am unable to find a function to change sampling rate in nRFX_SPIM code example.suggest me a exmple code in peripheral that can be merged in my original code and used in spi function to change sampling rate.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;rohit&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158682?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 14:41:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c7871a8-9d5e-4d39-a3e1-2369c027ae0f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Looks like you are sampling the SPI&amp;nbsp;with too slow sampling rate setting, then you get strange waveform. You need to reduce SPI speed or increase sample rate (preferred).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158638?ContentTypeID=1</link><pubDate>Thu, 22 Nov 2018 13:12:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a83051a-7957-4ca5-8730-aeb321d799c4</guid><dc:creator>rohit</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Explanation:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It depends on how I set&amp;nbsp;spi_xfer_done in the SPIM callback handler.&amp;nbsp; I should set it false before transfer, then set it true in the callback.&amp;nbsp; then I have to loop in the while as long as the flag is not set true. Now I will skip the loop as the flag is not set to true (I set it to false right before&amp;nbsp;nrfx_spim_xfer).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for my&amp;nbsp;driver recovery. I have changed the code as per your suggestion. And Its work fine.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I get data in TX and RX buffer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I am not getting correct waveform please check my SPI configuration.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In my requirement timing of the SPI should be as in the attached image below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1542892062325v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;but I am getting below waveform it is totally wrong. I am not sure about my SPI Configuration so please check it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/MISO-Channel-3-_2C00_-CS-channel-7_2C00_-SCK-9-and-13-MOSI-.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;MISO Channel 3 , CS channel 7, SCK &lt;span&gt;Channel&amp;nbsp;&amp;nbsp;&lt;/span&gt;9 and&amp;nbsp;&lt;span&gt;Channel&amp;nbsp;&lt;/span&gt; 13 MOSI.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;nrfx_spim.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;MAX30003.h&amp;quot;


#define NRFX_SPIM_SCK_PIN  3
#define NRFX_SPIM_MOSI_PIN 4
#define NRFX_SPIM_MISO_PIN 28
#define NRFX_SPIM_SS_PIN   29
#define NRFX_SPIM_DCX_PIN  30

#define SPI_INSTANCE  3                                           /**&amp;lt; SPI instance index. */
const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */

volatile bool spi_xfer_done;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */
uint8_t m_tx_buf[4]; //= {0xff,0x01,0x02}; // ={0x0F}; // 32 bit transfers
uint8_t       m_rx_buf[sizeof(m_tx_buf)];  /**&amp;lt; RX buffer. */
const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */
nrfx_spim_xfer_desc_t xfer_desc=NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));


void spim_event_handler(nrfx_spim_evt_t const * p_event,
                       void *                  p_context)
{
	

    spi_xfer_done = true;
    NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}
uint8_t MAX30003_Reg_Read(uint8_t Reg_address)
{
  nrfx_err_t err_code = 0;	
  uint32_t data;
  //Prepare the tx buffer
   memset(m_rx_buf, 0x00, sizeof(m_rx_buf)); // Erases the buffer
  m_tx_buf[0] = ((Reg_address &amp;lt;&amp;lt; 1) | 0x01); 
  //Create the transfer descriptor
 // nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));
  //Initiate the transfer
  spi_xfer_done = false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == false);
  data |= (m_rx_buf[1] &amp;lt;&amp;lt; 16);
  data |= (m_rx_buf[2] &amp;lt;&amp;lt; 8);
  data |= m_rx_buf[3];
  return data;
}

uint8_t MAX30003_Reg_Write(uint8_t Reg_address,  uint32_t data)
{
  nrfx_err_t err_code = 0;	
  //Prepare the tx buffer
  memset(m_rx_buf, 0x00, sizeof(m_rx_buf)); // Erases the buffer
  m_tx_buf[0] = ((Reg_address &amp;lt;&amp;lt; 1) | 0x01); 
//  //Create the transfer descriptor
//   nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));
//  //Initiate the transfer
  spi_xfer_done = false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == false);
  data |= (m_rx_buf[1] &amp;gt;&amp;gt; 16);
  data |= (m_rx_buf[2] &amp;gt;&amp;gt; 8);
  data |= m_rx_buf[3];
  return data;
}
void max30003_sw_reset(void)
{
    MAX30003_Reg_Write(SW_RST,0x000000);     
    nrf_delay_ms(100);
}

void max30003_synch(void)
{
    MAX30003_Reg_Write(SYNCH,0x000000);
}
void MAX30003_begin()
{    
    max30003_sw_reset();
    MAX30003_Reg_Write(CNFG_GEN, 0x081007);
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_CAL, 0x720000);  // 0x700000  
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_EMUX,0x0B0000);
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_ECG, 0x805000);  // 
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_RTOR1,0x3fc600);
    max30003_synch();
    nrf_delay_ms(100);
}

int main(void)
{
bsp_board_init(BSP_INIT_LEDS);
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();
nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
spi_config.frequency = SPIM_FREQUENCY_FREQUENCY_M1;
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.use_hw_ss = true;
spi_config.ss_active_high = false;
spi_config.mode = NRF_SPIM_MODE_0; // SCK active high, sample on leading edge of clock, CPOL=0/CPHA=0
spi_config.bit_order=NRF_SPIM_BIT_ORDER_LSB_FIRST; 
//nrfx_spim_xfer_desc_t xfer_desc=NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));
	
APP_ERROR_CHECK(nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL));

	NRF_LOG_INFO(&amp;quot;NRFX SPIM example started.&amp;quot;);
while (1)
{
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_length);
spi_xfer_done = false;
MAX30003_Reg_Read(INFO); //0x0F
APP_ERROR_CHECK(nrfx_spim_xfer_dcx(&amp;amp;spi, &amp;amp;xfer_desc, 0, 15)); 

while (!spi_xfer_done)
{
	
__WFE();
}
NRF_LOG_FLUSH();
bsp_board_led_invert(BSP_BOARD_LED_0);
nrf_delay_ms(200);
}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards,&lt;/p&gt;
&lt;p&gt;Rohit.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158499?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 19:34:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0929626-8ada-41e3-b569-1dc763b81d68</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Can you explain how the following code works?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  spi_xfer_done == false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == true);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I would think it should be:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  spi_xfer_done = false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == false);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When it doubt, go back to the working example in the SDK:&lt;/p&gt;
&lt;p&gt;\nRF5_SDK_15.1.0_a8c0c4d\examples\peripheral\nrfx_spim&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/158423?ContentTypeID=1</link><pubDate>Wed, 21 Nov 2018 13:25:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f13fbc3-abae-4b79-9c6e-3d74c71b33df</guid><dc:creator>rohit</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;I am not satisfied with&amp;nbsp;your answer. We are working with the max30003 sensor and we plan to record ECG data with it.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I am referred below link because the same problem is coming into my code :&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/38483/using-nrf52832-as-spi-master-to-get-data-from-sensor/148560#148560"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/38483/using-nrf52832-as-spi-master-to-get-data-from-sensor/148560#148560&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have used the SDK example as reference:&amp;nbsp;\nRF5_SDK_15.1.0\examples\peripheral\nRFX_SPIM.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;I Have done reg read and reg write driver as per MAXIM Drivers (.cpp and.h file) Please see the below&amp;nbsp;link:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://www.maximintegrated.com/en/products/analog/data-converters/analog-front-end-ics/MAX30003.html"&gt;https://www.maximintegrated.com/en/products/analog/data-converters/analog-front-end-ics/MAX30003.html&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But My problem is that:&lt;/p&gt;
&lt;p&gt;1) I don&amp;#39;t know Written Driver is correct or not as per MAXIM? and I unable to read INFO Register Correctly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) If I Read 0x0F register then I Got below waveform and data in RX Buffer.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/wf1-op.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/WF1-Hantek.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Probing: MOSI For Yellow and Blue for SCK Pin&lt;/p&gt;
&lt;p&gt;3) but Even without calling the Reg_Read function into the main function then also data is coming in to RX Buffer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/wf2-Op.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/WF2-Hantek.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Probing: MOSI For Yellow and Blue for SCK Pin&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In my requirement timing of the SPI should be as in the attached image below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1542806747501v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I am pretty sure that my SPI&amp;nbsp;configurations are not proper, please provide me a pointer where I can do the SPI configurations to meet the timing requirements detailed above.&lt;/p&gt;
&lt;p&gt;Expecting your kind help.&lt;/p&gt;
&lt;p&gt;please check below code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;nrfx_spim.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;MAX30003.h&amp;quot;


#define NRFX_SPIM_SCK_PIN  3
#define NRFX_SPIM_MOSI_PIN 4
#define NRFX_SPIM_MISO_PIN 28
#define NRFX_SPIM_SS_PIN   29
#define NRFX_SPIM_DCX_PIN  30

#define SPI_INSTANCE  3                                           /**&amp;lt; SPI instance index. */
static const nrfx_spim_t spi = NRFX_SPIM_INSTANCE(SPI_INSTANCE);  /**&amp;lt; SPI instance. */

static volatile bool spi_xfer_done;  /**&amp;lt; Flag used to indicate that SPI instance completed the transfer. */
static  uint8_t m_tx_buf[4]; //= {0xff,0x01,0x02}; // ={0x0F}; // 32 bit transfers
static uint8_t       m_rx_buf[sizeof(m_tx_buf)];  /**&amp;lt; RX buffer. */
static const uint8_t m_length = sizeof(m_tx_buf);        /**&amp;lt; Transfer length. */


void spim_event_handler(nrfx_spim_evt_t const * p_event,
                       void *                  p_context)
{
    spi_xfer_done = true;
    NRF_LOG_INFO(&amp;quot;Transfer completed.&amp;quot;);
    if (m_rx_buf[0] != 0)
    {
        NRF_LOG_INFO(&amp;quot; Received:&amp;quot;);
        NRF_LOG_HEXDUMP_INFO(m_rx_buf, strlen((const char *)m_rx_buf));
    }
}
uint8_t MAX30003_Reg_Read(uint8_t Reg_address)
{
  nrfx_err_t err_code = 0;	
  uint8_t data;
  //Prepare the tx buffer
  memset(m_rx_buf, 0x00, sizeof(m_rx_buf)); // Erases the buffer
  m_tx_buf[0] = ((Reg_address &amp;lt;&amp;lt; 1 ) | 0x01); 
  //Create the transfer descriptor
  nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));
  //Initiate the transfer
  spi_xfer_done == false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == true);
  data |= (m_rx_buf[1] &amp;lt;&amp;lt; 16);
  data |= (m_rx_buf[2] &amp;lt;&amp;lt; 8);
  data |= m_rx_buf[3];
  return data;
}
uint8_t MAX30003_Reg_Write(uint8_t Reg_address,  uint32_t data)
{
   nrfx_err_t err_code = 0;	
  //Prepare the tx buffer
  memset(m_rx_buf, 0x00, sizeof(m_rx_buf)); // Erases the buffer
  m_tx_buf[0] = ((Reg_address &amp;lt;&amp;lt; 1) | 0x00); 
  //Create the transfer descriptor
   nrfx_spim_xfer_desc_t xfer_desc = NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));
  //Initiate the transfer
  spi_xfer_done == false;
  err_code = nrfx_spim_xfer(&amp;amp;spi, &amp;amp;xfer_desc, 0);
  APP_ERROR_CHECK(err_code);
  while (spi_xfer_done == true);
  data |= (m_rx_buf[1] &amp;gt;&amp;gt; 16);
  data |= (m_rx_buf[2] &amp;gt;&amp;gt; 8);
  data |= m_rx_buf[3];
  return data;
}
void max30003_sw_reset(void)
{
    MAX30003_Reg_Write(SW_RST,0x000000);     
    nrf_delay_ms(100);
}

void max30003_synch(void)
{
    MAX30003_Reg_Write(SYNCH,0x000000);
}
void MAX30003_begin()
{    
    max30003_sw_reset();
    MAX30003_Reg_Write(CNFG_GEN, 0x081007);
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_CAL, 0x720000);  // 0x700000  
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_EMUX,0x0B0000);
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_ECG, 0x805000);  // 
    nrf_delay_ms(100);
    MAX30003_Reg_Write(CNFG_RTOR1,0x3fc600);
    max30003_synch();
    nrf_delay_ms(100);
}
int main(void)
{
bsp_board_init(BSP_INIT_LEDS);
APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();
	
//MAX30003_Reg_Read(0x0F); //0x0F


nrfx_spim_config_t spi_config = NRFX_SPIM_DEFAULT_CONFIG;
spi_config.frequency = SPIM_FREQUENCY_FREQUENCY_M1;
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.use_hw_ss = true;
spi_config.ss_active_high = false;
spi_config.mode = NRF_SPIM_MODE_0; // SCK active high, sample on leading edge of clock, CPOL=0/CPHA=0
spi_config.bit_order=NRF_SPIM_BIT_ORDER_LSB_FIRST; 

nrfx_spim_xfer_desc_t xfer_desc=NRFX_SPIM_XFER_TRX(m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_tx_buf));

APP_ERROR_CHECK(nrfx_spim_init(&amp;amp;spi, &amp;amp;spi_config, spim_event_handler, NULL));

NRF_LOG_INFO(&amp;quot;NRFX SPIM example started.&amp;quot;);

while (1)
{
// Reset rx buffer and transfer done flag
memset(m_rx_buf, 0, m_length);

spi_xfer_done = false;
APP_ERROR_CHECK(nrfx_spim_xfer_dcx(&amp;amp;spi, &amp;amp;xfer_desc, 0, 15)); 

while (!spi_xfer_done)
{
	
__WFE();
}
NRF_LOG_FLUSH();
bsp_board_led_invert(BSP_BOARD_LED_0);
nrf_delay_ms(200);
}
}&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards,&lt;/p&gt;
&lt;p&gt;rohit&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nrf SPI Timing Configurations</title><link>https://devzone.nordicsemi.com/thread/157957?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 12:54:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dcaf1d7-bf95-4aec-b772-41a7be49fa92</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I assume you have used the SDK example as reference:&amp;nbsp;\nRF5_SDK_15.2.0_9412b96\examples\peripheral\spi&amp;nbsp;&lt;br /&gt;(&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/hardware_driver_spi_master.html?cp=4_0_0_2_0_13"&gt;http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.2.0/hardware_driver_spi_master.html?cp=4_0_0_2_0_13&lt;/a&gt;)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The timing you refer are okey, these are just min and max values, and should fall well within the timing of the spi master of the nRF52. For instance it says the clock frequency should be between 0 and 12MHz, which means you can for instance use 1MHz clock rate.&lt;/p&gt;
&lt;p&gt;I think you should zoom into your plot, I suspect you have an SPI transfer every 250ms(? timing not shown) here.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>