<?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>spi configuration related issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35536/spi-configuration-related-issue</link><description>HI all 
 I am facing SPI cofiguration issue on nRF 52 DK.I am using PAJ7025R2 sensor and will act as a slave, and nRF52 acts as a master.Currently i am not getting any data from MISO pin. 
 I am using spi example as a reference. 
 configuration settings</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 08 Apr 2019 06:14:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35536/spi-configuration-related-issue" /><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/180637?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2019 06:14:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdb59d03-d335-4523-a361-e2248c905f70</guid><dc:creator>akash naidu</dc:creator><description>&lt;p&gt;check this spi configuration..&lt;pre class="ui-code" data-mode="text"&gt;int spiInit(void){
  //Structure for SPI master configuration, initialized by default values.
  spi_master_config_t spi_instance =  SPI_MASTER_INIT_DEFAULT;
  
  spi_instance.SPI_Pin_SCK  = 12;	
  spi_instance.SPI_Pin_MOSI = 14;
  spi_instance.SPI_Pin_MISO = 13;
  spi_instance.SPI_Pin_SS   = 15;
  
  spi_instance.SPI_CONFIG_CPOL = SPI_CONFIG_CPOL_ActiveLow;
  spi_instance.SPI_CONFIG_CPHA = SPI_CONFIG_CPHA_Trailing;
  
  spi_instance.SPI_CONFIG_ORDER = SPI_CONFIG_ORDER_LsbFirst;
  spi_instance.SPI_Freq = SPI_FREQUENCY_FREQUENCY_M8; // 125 Hz.
  
  spi_instance.SPI_PriorityIRQ = NRF_APP_PRIORITY_HIGH;	//with softdevice enabled.
  
  
  //Initialize SPI master.
  uint32_t err_code = spi_master_open(SPI_MASTER_0, &amp;amp;spi_instance);// init the SPI0 Instance.
  if( err_code == NRF_ERROR_INVALID_STATE ){
    
    return 2;
  }
  else if( err_code == NRF_ERROR_NULL ){
    
    return 3;
  }
  else if( err_code == NRF_ERROR_NOT_SUPPORTED ){
    
    return 4;
  }
  else if(err_code != NRF_SUCCESS){
    return 0;
  }
  //else it is good to go now.
  
  //Register SPI master event handler.
  spi_master_evt_handler_reg( SPI_MASTER_0, spi_master_event_handler);
  return 1;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;spi event code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void spi_master_event_handler(spi_master_evt_t spi_master_evt){
  switch(spi_master_evt.evt_type){
  case SPI_MASTER_EVT_TRANSFER_COMPLETED:
    // printf (&amp;quot;SPI_MASTER_EVT_TRANSFER_COMPLETED\r\n&amp;quot;);
    //Transmission done.
    transmission_completed_spi = true;
    //rx_buffer must have received data now.
    break;
  default:
    // no implementation is required for now.
    break;
  }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;for read/write spi API&lt;/p&gt;
&lt;p&gt;spi_master_send_recv(SPI_MASTER_0, tx_buffer_spi, TX_RX_MSG_LENGTH, rx_buffer_spi, TX_RX_MSG_LENGTH);&lt;/p&gt;
&lt;p&gt;i hope this could be helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/180496?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 12:40:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0661d608-d34d-42ba-ab40-4bf7e7604458</guid><dc:creator>masterLee</dc:creator><description>&lt;p&gt;Could you please share the solution since I am facing the same problem?? Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/156263?ContentTypeID=1</link><pubDate>Wed, 07 Nov 2018 07:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45b4ba63-60f2-44e1-9bb9-2bc9a4a485ad</guid><dc:creator>akash naidu</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;I forgot to give reply.&lt;/p&gt;
&lt;p&gt;My problem has been resolved since 2 months back.&lt;/p&gt;
&lt;p&gt;Thanks for support.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Akash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/137246?ContentTypeID=1</link><pubDate>Fri, 22 Jun 2018 12:29:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8f7e9ec8-9ad4-4a1f-bec3-66c47ecc2458</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Akash,&lt;/p&gt;
&lt;p&gt;Could you compare the MOSI with SCLK (as well as SS) for the STM32 and the nRF52 to see that they actually behave the same?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think that will give you a good clue what is going on.&lt;/p&gt;
&lt;p&gt;I want to confirm that the data sent out of the STM32 is exactly the same as the data sent out from nRF52. (&lt;em&gt;but my hunch is that this is not the case)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/136889?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 11:34:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfd7a5f6-8528-4f9c-969f-224586565be4</guid><dc:creator>akash naidu</dc:creator><description>&lt;p&gt;My slave is supports SPI3(CPOL = 1,CPHA = 1) mode, and 14Mhz frequency.&lt;/p&gt;
&lt;p&gt;below code is for STM32 master configuration..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  /* SPI1 parameter configuration*/
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have verified all signals(SCK,SS,MOSI) over C.R.O.I have been getting all signals properly.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static uint8_t m_tx_buf[] = {0x80,0x02}; /**&amp;lt; TX buffer. */&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;i am sending 2 bytes of data.&lt;/p&gt;
&lt;p&gt;first byte is used to set as read mode in slave.&lt;/p&gt;
&lt;p&gt;second byte is used to read the chip id of the slave.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/136878?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 09:42:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:099cb221-4e23-4a07-97fb-e278c33fe51d</guid><dc:creator>Martin Lesund</dc:creator><description>[quote user="akash naidu"]is there any configuration required that changing shifting bit(MSB/LSB) and mode(0,1,2,3)?[/quote]
&lt;p&gt;You change that in:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define NRF_DRV_SPI_DEFAULT_CONFIG \
{ \
.sck_pin = NRF_DRV_SPI_PIN_NOT_USED, \
.mosi_pin = NRF_DRV_SPI_PIN_NOT_USED, \
.miso_pin = NRF_DRV_SPI_PIN_NOT_USED, \
.ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \
.irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \
.orc = 0xFF, \
.frequency = NRF_DRV_SPI_FREQ_8M, \
.mode = NRF_DRV_SPI_MODE_3, \
.bit_order = NRF_DRV_SPI_BIT_ORDER_LSB_FIRST, \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;According to what the mode/freq. your slave requires.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What configurations did you&amp;nbsp;set for the STM32 master?&lt;/p&gt;
&lt;p&gt;Did you check every signal from master-slave? sclk,ss ....&lt;/p&gt;
&lt;p&gt;What are you sending to the slave?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/136843?ContentTypeID=1</link><pubDate>Wed, 20 Jun 2018 07:28:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eabcc21a-0868-4b45-8510-877b7f2b5a07</guid><dc:creator>akash naidu</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;yes. I am using&amp;nbsp;&amp;nbsp;&lt;em&gt;[nRF5_SDK_15.0\examples\peripheral\spi\&lt;/em&gt;&lt;span&gt;] as a reference.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;yes. I am using same pins which are defined in sdk_config.h(SS = 29,MISO = 28,MOSI = 4,SCK = 3), and i have connected the connections properly.&lt;/p&gt;
&lt;p&gt;And i have verified the data(over MOSI pin) over C.R.O, where i am getting&amp;nbsp; &lt;span&gt;expecting data.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But i am not getting any data(if i probe on MISO pin) from slave device.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;is there any configuration required that changing shifting bit(MSB/LSB) and mode(0,1,2,3)?&lt;/p&gt;
&lt;p&gt;I am trying to read chip id of slave device, but i was not getting any response from device.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For same slave device, i worked on STM32 where it was working fine.&lt;/p&gt;
&lt;p&gt;below code is for configuration settings.&lt;/p&gt;
&lt;p&gt;#define NRF_DRV_SPI_DEFAULT_CONFIG \&lt;br /&gt;{ \&lt;br /&gt; .sck_pin = NRF_DRV_SPI_PIN_NOT_USED, \&lt;br /&gt; .mosi_pin = NRF_DRV_SPI_PIN_NOT_USED, \&lt;br /&gt; .miso_pin = NRF_DRV_SPI_PIN_NOT_USED, \&lt;br /&gt; .ss_pin = NRF_DRV_SPI_PIN_NOT_USED, \&lt;br /&gt; .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY, \&lt;br /&gt; .orc = 0xFF, \&lt;br /&gt; .frequency = NRF_DRV_SPI_FREQ_8M, \&lt;br /&gt; .mode = NRF_DRV_SPI_MODE_3, \&lt;br /&gt; .bit_order = NRF_DRV_SPI_BIT_ORDER_LSB_FIRST, \&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;span&gt;nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;spi_config.ss_pin = SPI_SS_PIN;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;spi_config.miso_pin = SPI_MISO_PIN;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;spi_config.mosi_pin = SPI_MOSI_PIN;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;spi_config.sck_pin = SPI_SCK_PIN;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;finally,i am not getting any response from slave device.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;akash.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: spi configuration related issue</title><link>https://devzone.nordicsemi.com/thread/136755?ContentTypeID=1</link><pubDate>Tue, 19 Jun 2018 12:44:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fafe7228-f55d-4af9-833b-fd221f825eee</guid><dc:creator>Martin Lesund</dc:creator><description>&lt;p&gt;Hi Akash,&lt;/p&gt;
&lt;p&gt;I assume that you are using the SPI example found in &lt;a href="http://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/" target="_blank" rel="noopener noreferrer"&gt;SDKv15&lt;/a&gt; in folder &lt;em&gt;[nRF5_SDK_15.0\examples\peripheral\spi\&lt;/em&gt;] as reference?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;No it is not required to change anything on the low level.&lt;/p&gt;
&lt;p&gt;I am interested if you have connected to the correct pins as the pins are defined in the sdk_config.h? (&lt;em&gt;from the default unmodified example it should be the pins commented)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin   = SPI_SS_PIN;  		// pin 29
    spi_config.miso_pin = SPI_MISO_PIN;  //  pin 28
    spi_config.mosi_pin = SPI_MOSI_PIN;  //  pin  4
    spi_config.sck_pin  = SPI_SCK_PIN;   //  pin  3
    APP_ERROR_CHECK(nrf_drv_spi_init(&amp;amp;spi, &amp;amp;spi_config, spi_event_handler, NULL));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Please check the pins with a logic analyzer such as &lt;a href="https://www.saleae.com/" target="_blank" rel="noopener noreferrer"&gt;saleae&lt;/a&gt;&amp;nbsp;or use a scope on those pins to double check that you actually are sending the correct data out of the chosen pins.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Martin L.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>