<?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>nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34731/nrf52-spi-pins-incompatibility</link><description>Hi, i&amp;#39;m using nRF52 DK to communicate CX93510 encoder chip via SPI. I&amp;#39;m using nrf_drv_spi library with SPI0 connected to pins: 
 
 #define CX93510_MISO_PIN 22 #define CX93510_MOSI_PIN 23 #define CX93510_SCK_PIN 24 #define CX93510_CS_PIN 25 #define CX93510_PDRAM_PIN</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 Jun 2018 11:25:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34731/nrf52-spi-pins-incompatibility" /><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134902?ContentTypeID=1</link><pubDate>Wed, 06 Jun 2018 11:25:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46634140-a8a1-41fe-a07c-dc3d5fad3c45</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;You are right, increasing frequency to 4 MHz and pulling MISO line to VCC made the diagram much better:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2018_2D00_06_2D00_06_5F00_14_2D00_20_2D00_03.png" /&gt;&lt;/p&gt;
&lt;p&gt;There are still problems with read transaction (last byte), but i think it is out of this topic.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you for help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134676?ContentTypeID=1</link><pubDate>Tue, 05 Jun 2018 08:12:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b36ffd96-e594-4188-9eec-d551cf208ce0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Fom your initial images it does not look like any of the devices is clocking the SCK line within 3µs. Is the timing on the images correct, or is does it show wrong resolution? The clock frequency on the second image also looks way lower than 1 MHz that you set in the code. Is the frequency correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134522?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2018 11:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5fa6275-6a36-45f2-8829-b02ba9c17fad</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;Looks like the problem is the interface selection algorithm of CX93510. It needs SCK line be clocked not later than 3us after CS goes low. Another way it selects UART as host interface&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134383?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 13:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a569239-2656-461c-ae26-f8c6b9bb6b37</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Is the&amp;nbsp;CX93510 chip mounted on some external module or PCB? Is it connected directly to the DK, or is there some other components connected to the SPI lines?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134325?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 10:20:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7f0794c-4327-4ff6-aece-e59eaf0dd5be</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;Yes, it works good. I can see it right now&lt;/p&gt;
&lt;p&gt;I guess it is not software problem, but i can&amp;#39;t undrstand what exactly wrong with hardware&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134322?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 10:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43efe5ba-7309-484d-bacc-50f898dcdae5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Have you checked the SPI bus with the logic analyzer without the slave device connected and with the same application?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/134315?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 09:32:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:badd805a-9e3a-4727-ab20-53b8cd63c3a3</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;Buffers are ok, but after transaction there is no event of successful transaction generated.&lt;br /&gt;&lt;br /&gt;Tryied with another nRF52 board, behaviour is the same&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/133826?ContentTypeID=1</link><pubDate>Tue, 29 May 2018 13:01:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a17716c6-aade-40b7-8ab8-6d9d07c95863</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Thank you. Did you try debugging the application? Please check the content of&amp;nbsp;tx_buffer right before call to nrf_drv_spi_transfer().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/133633?ContentTypeID=1</link><pubDate>Mon, 28 May 2018 11:28:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abae2e5c-1c39-469a-b865-b7d42bff1eba</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;There is the datasheet file for CX93510:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4540.CX93510-Reflector-DSH_2D00_202155_2D00_003.pdf"&gt;devzone.nordicsemi.com/.../4540.CX93510-Reflector-DSH_2D00_202155_2D00_003.pdf&lt;/a&gt;&amp;nbsp;. Host interfaces are described at page 45.&lt;br /&gt;This device requires not much time (a few ns) after CS goes low to clock out data.&lt;/p&gt;
&lt;p&gt;Yes, there are differences in timing and i dont know why, SPI configuration is the same at both diagrams.&lt;/p&gt;
&lt;p&gt;First 0x00 byte specifies the &amp;quot;read register&amp;quot; command, next byte (here it is 0x50) is register address, 3rd byte should be 0x00. After this actions one byte of data should be clocked out from the device.&lt;/p&gt;
&lt;p&gt;Below is the diagram of communicating to this device with STM8 controller. First transmittion is needed for interface selecting as described in datasheet, the second gives us valid output data (0x01)&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x240/__key/communityserver-discussions-components-files/4/0724.2018_2D00_05_2D00_28_5F00_14_2D00_25_2D00_51.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/133623?ContentTypeID=1</link><pubDate>Mon, 28 May 2018 10:44:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e74b495-0b74-4b17-8425-59bcb5d363e7</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Do you have a datasheet for the&amp;nbsp;CX93510 device that you could share? Is the device able to clock out data immediately after the CS line is asserted? From the two logic trances there seems to be some difference in timing. What is the device supposted to clock out? Is 0x00 transferred from the master configuring the device in any way, or does it not need any configuration?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/133524?ContentTypeID=1</link><pubDate>Sat, 26 May 2018 09:04:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0940dde0-48fd-4813-9380-976e49c075a9</guid><dc:creator>Magners</dc:creator><description>&lt;p&gt;Thank you for response!&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using SDK 14.2, SPI0 configured as CPOL=0, CPHA=0, no pull on MISO line and not using EasyDMA.&lt;/p&gt;
&lt;p&gt;As i mentioned i&amp;#39;m able to see data output on the SPI bus when it is unplugged from&amp;nbsp;slave device CX93510. Also i dont have any troubles with communication to other SPI devices without any changing initialization code (for example SX1276).&lt;/p&gt;
&lt;p&gt;Problem appears when i connect CX93510 IC to SPI and I know it looks like this IC is broken or something like this, BUT i&amp;#39;m able to communicate to it with another microcontroller. SPI mode and timings are the same, but STM8 works good and nRF52 fails.&lt;br /&gt;&lt;br /&gt;My initialization code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void cx93510_periph_config (void)
{
	nrf_drv_gpiote_init();
	nrf_drv_gpiote_out_config_t cx93510_out_config = GPIOTE_CONFIG_OUT_SIMPLE(true);
	APP_ERROR_CHECK(nrf_drv_gpiote_out_init(CX93510_CS_PIN, &amp;amp;cx93510_out_config));
	APP_ERROR_CHECK(nrf_drv_gpiote_out_init(CX93510_PD_PIN, &amp;amp;cx93510_out_config));
	APP_ERROR_CHECK(nrf_drv_gpiote_out_init(CX93510_PDRAM_PIN, &amp;amp;cx93510_out_config));
	
	nrf_drv_spi_config_t cx93510_spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
	cx93510_spi_config.miso_pin =	CX93510_MISO_PIN;
	cx93510_spi_config.mosi_pin = CX93510_MOSI_PIN;
	cx93510_spi_config.sck_pin = CX93510_SCK_PIN;
	cx93510_spi_config.mode = NRF_DRV_SPI_MODE_0;
	cx93510_spi_config.frequency = NRF_DRV_SPI_FREQ_1M;
	APP_ERROR_CHECK( nrf_drv_spi_init(&amp;amp;spi_cx93510, &amp;amp;cx93510_spi_config, spi_cx93510_event_handler, NULL) );

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;SPI event handler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void spi_cx93510_event_handler(nrf_drv_spi_evt_t const * p_event, void * p_context)
{
	spi_cx93510_busy = false;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Transmit and Recieve code:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void spi_recieve_buffer(uint8_t *rx_buffer, uint16_t size)
{
	uint32_t timeout = SPI_TIMEOUT;
	uint8_t tx_buffer[size];
	
	// waiting last transmittion complete
	while (spi_cx93510_busy &amp;amp;&amp;amp; timeout--);
	timeout = SPI_TIMEOUT;
	
	APP_ERROR_CHECK (nrf_drv_spi_transfer(&amp;amp;spi_cx93510, tx_buffer, size, rx_buffer, size) );
	spi_cx93510_busy = true;
	
	while (spi_cx93510_busy &amp;amp;&amp;amp; timeout--);
}

static void spi_transmite_buffer(uint8_t *tx_buffer, uint16_t size)
{
	uint32_t timeout = SPI_TIMEOUT;
	uint8_t rx_buffer[size];
	
	// waiting last transmittion complete
	while (spi_cx93510_busy &amp;amp;&amp;amp; timeout--);
	timeout = SPI_TIMEOUT;
	
	APP_ERROR_CHECK( nrf_drv_spi_transfer(&amp;amp;spi_cx93510, tx_buffer, size, rx_buffer, size) );
	spi_cx93510_busy = true;
	
	while (spi_cx93510_busy &amp;amp;&amp;amp; timeout--);

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Accesing CX93510 registers:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void codec_read (uint8_t* pbuf, uint8_t len)
{
    uint8_t buf[3];

    buf[0] = 0;
    buf[1] = *pbuf;
    buf[2] = 0;

    CX93510_CS_CLEAR;

    spi_transmite_buffer (&amp;amp;buf[0], 3);

    spi_recieve_buffer (pbuf, len);

    CX93510_CS_SET;
}

void codec_write (uint8_t* pbuf, uint8_t len)
{
    uint8_t buf[3];

    buf[0] = (uint8_t) 0x80;
    buf[1] = *pbuf;
    buf[2] = 0;

    CX93510_CS_CLEAR;

    spi_transmite_buffer (&amp;amp;buf[0], 3);

    spi_transmite_buffer (pbuf + 1, len - 1);

    CX93510_CS_SET;

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And what i&amp;#39;m trying to transfer (it is shown in diagrams at topic start):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void cx93510_init (void)
{	
	uint8_t tmp8;
	uint8_t buf[6];
	uint8_t sensor_pid_msb, sensor_pid_lsb;
	
	do
  {
		CX93510_PDRAM_CLEAR;
		CX93510_PD_CLEAR;
		
		nrf_delay_ms(1);
		
		CX93510_PDRAM_SET;
		CX93510_PD_SET;	

		nrf_delay_ms(5);
		
		tmp8 = (uint8_t) 0x50;
    codec_read (&amp;amp;tmp8, 1);

    tmp8 = (uint8_t) 0x50;
    codec_read (&amp;amp;tmp8, 1);
  } 
	while (1);// ((tmp8 &amp;amp; (uint8_t) 0x03) != (uint8_t) 0x01);      // waiting Conexant to answer
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 SPI pins incompatibility</title><link>https://devzone.nordicsemi.com/thread/133424?ContentTypeID=1</link><pubDate>Fri, 25 May 2018 12:17:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:373bfc48-6cfd-473e-9c05-bc07cbe7b102</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you post some code showing how you configure the SPI interface, and how/what you transfer to the device?&lt;/p&gt;
&lt;p&gt;Are you able to see data output on the SPI bus if you flash the board with the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/spi_master_example.html?cp=4_0_0_4_5_36"&gt;SPI example&lt;/a&gt;&amp;nbsp;from the SDK? Also, which SDK version are you using?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>