<?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>Attempting SPIM3 reads with MOSI and MISO Tied Together</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74654/attempting-spim3-reads-with-mosi-and-miso-tied-together</link><description>Hello, 
 
 We are currently using SDK v17.0.2 with NRF52840, driving a display with SPIM3. We are able to successfully communicate with our display and command it to render various things. Because it&amp;#39;s a display, we have MOSI and MISO tied together as</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 May 2021 11:58:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74654/attempting-spim3-reads-with-mosi-and-miso-tied-together" /><item><title>RE: Attempting SPIM3 reads with MOSI and MISO Tied Together</title><link>https://devzone.nordicsemi.com/thread/307905?ContentTypeID=1</link><pubDate>Mon, 03 May 2021 11:58:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ca1e7d1-8684-4014-a277-94d4d2765e4e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Typically you can solve this by adding a 1kohm resistor on MOSI as shown in the figure here:&lt;br /&gt;&lt;a href="https://os.mbed.com/questions/69051/SPI-Halfduplex-MOSI-3-wire-read-support-/"&gt;https://os.mbed.com/questions/69051/SPI-Halfduplex-MOSI-3-wire-read-support-/&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Typically the input buffer on MISO then will reflect data on MOSI, unless DOUT drives the line.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Attempting SPIM3 reads with MOSI and MISO Tied Together</title><link>https://devzone.nordicsemi.com/thread/307770?ContentTypeID=1</link><pubDate>Sat, 01 May 2021 20:18:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7855e56-86f6-4d09-aecc-4970f9b92847</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;3-wire SPI doesn&amp;#39;t have a MISO line but instead a bi-directional data line - effectively a MOSI and MISO combo. Usually used when pin count is at a premium; often 4-wire SPI devices have a command setting that allows changing to 3-wire SPI mode.&lt;/p&gt;
&lt;p&gt;I agree it would be helpful to know which E-ink display is being used, and a schematic would be useful. I use E-ink displays but I don&amp;#39;t recall using one with a readable temperature sensor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Attempting SPIM3 reads with MOSI and MISO Tied Together</title><link>https://devzone.nordicsemi.com/thread/307743?ContentTypeID=1</link><pubDate>Sat, 01 May 2021 08:53:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae1a54f8-ff3b-4765-9bd0-4fc251525db6</guid><dc:creator>awneil</dc:creator><description>[quote userid="24036" url="~/f/nordic-q-a/74654/attempting-spim3-reads-with-mosi-and-miso-tied-together"]&lt;p&gt;(the display does not utilize a MISO line).&lt;/p&gt;
&lt;p&gt;I am currently attempting to read back the temperature from the display&lt;/p&gt;[/quote]
&lt;p&gt;If the display doesn&amp;#39;t use MISO, how can you possibly read anything from it?&lt;/p&gt;
&lt;p&gt;I think you need to give more details of how you &lt;em&gt;expect&lt;/em&gt; this to work.&lt;/p&gt;
&lt;p&gt;Including a schematic, and links to the display in question would also help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Attempting SPIM3 reads with MOSI and MISO Tied Together</title><link>https://devzone.nordicsemi.com/thread/307734?ContentTypeID=1</link><pubDate>Fri, 30 Apr 2021 22:52:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0379a006-c131-45bd-84b4-e4d1d2150ed1</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The SPI code you are using assumes 4-wire SPI, but to connect MOSI to MISO 3-wire SPI mode is required, which I don&amp;#39;t think the driver you are using supports. Here is low-level code showing how it&amp;#39;s done:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void Test3WireSPI(void)
{
  NRF_GPIO-&amp;gt;PIN_CNF[CSPIN]   = 0x301;  // output, high drive high and low H0H1
  NRF_GPIO-&amp;gt;PIN_CNF[SCKPIN]  = 0x301;  // output, high drive high and low H0H1
  NRF_GPIO-&amp;gt;PIN_CNF[MOSIPIN] = 1;      // output, standard drive S0S1
  NRF_GPIO-&amp;gt;PIN_CNF[MISOPIN] = 0;      // input pin, input buffer connected, no pull, S0S1, sense disabled
  NRF_GPIO-&amp;gt;OUTSET = 1 &amp;lt;&amp;lt; CSPIN;       // deactivate by setting chip select high
  NRF_SPIM3-&amp;gt;PSEL.SCK = SCKPIN;
  NRF_SPIM3-&amp;gt;PSEL.MOSI = MOSIPIN;
  NRF_SPIM3-&amp;gt;PSEL.MISO = 0xFFFFFFFFUL; // MISOPIN;
  NRF_SPIM3-&amp;gt;CONFIG = 0;               // CPOL 0 -- clock polarity active high, CPHA 1 -- sample on trailing clock edge, send Msb first
  NRF_SPIM3-&amp;gt;FREQUENCY = 0x80000000UL; // 8 Mbps
  NRF_SPIM3-&amp;gt;ORC =0;                   // Unused Tx bytes, set all low

  // Configure registers for 3-wire mode
  NRF_SPIM3-&amp;gt;PSEL.MOSI = MOSIPIN;
  NRF_SPIM3-&amp;gt;PSEL.MISO = 0xFFFFFFFFUL; // MISOPIN;
  NRF_GPIO-&amp;gt;PIN_CNF[MOSIPIN] = 1;      // output

  NRF_SPIM3-&amp;gt;EVENTS_ENDTX = 0;
  //NRF_SPIM3-&amp;gt;EVENTS_ENDRX = 0;

  // Disable all interrupts
  NRF_SPIM3-&amp;gt;INTENCLR = 0xFFFFFFFFUL;
  // Enable selected interrupts
  NRF_SPIM3-&amp;gt;INTENSET = 0x40;   // END

  // Set interrupt priority and enable interrupt
  NVIC_SetPriority(SPIM3_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn, 6);
  NVIC_ClearPendingIRQ(SPIM3_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn);
  NVIC_EnableIRQ(SPIM3_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQn);

  NRF_SPIM3-&amp;gt;ENABLE = 7;               // enable SPI
  // Transfer registers to set 3-wire SPI mode on target
  NRF_SPIM3-&amp;gt;TXD.PTR = (uint32_t)mACC_ControlRegisterRequiredSettings;
  NRF_SPIM3-&amp;gt;TXD.MAXCNT = sizeof(mACC_ControlRegisterRequiredSettings);
  NRF_SPIM3-&amp;gt;RXD.PTR = NULL;
  NRF_SPIM3-&amp;gt;RXD.MAXCNT = 0;

  NRF_GPIO-&amp;gt;OUTCLR = 1 &amp;lt;&amp;lt; CSPIN;    // drive cs low to initiate spi comm
  NRF_SPIM3-&amp;gt;TASKS_START = 1;
  while(!NRF_SPIM3-&amp;gt;EVENTS_ENDTX);  // last byte transmitted
  NRF_SPIM3-&amp;gt;TASKS_STOP = 1;
  NRF_GPIO-&amp;gt;OUTSET = 1 &amp;lt;&amp;lt; CSPIN;

  // Send 3-wire whoami command byte (1 byte only)
  // Connect output drive, connect 1-wire rx/tx output to MOSI
  NRF_SPIM3-&amp;gt;PSEL.MISO = 0xFFFFFFFF; // MISOPIN;
  NRF_SPIM3-&amp;gt;PSEL.MOSI = MOSIPIN;
  NRF_GPIO-&amp;gt;PIN_CNF[MOSIPIN] = 1;    // output
  NRF_SPIM3-&amp;gt;TXD.PTR = (uint32_t)spi3wTXBuf;
  NRF_SPIM3-&amp;gt;TXD.MAXCNT = 1;
  NRF_SPIM3-&amp;gt;RXD.PTR = NULL;
  NRF_SPIM3-&amp;gt;RXD.MAXCNT = 0;
  NRF_SPIM3-&amp;gt;EVENTS_ENDTX = 0;
  NRF_GPIO-&amp;gt;OUTCLR = 1 &amp;lt;&amp;lt; CSPIN;       // drive cs low to initiate spi comm
  NRF_SPIM3-&amp;gt;TASKS_START = 1;
  while(!NRF_SPIM3-&amp;gt;EVENTS_ENDTX);     // last byte transmitted

  // Manual says disable SPI before changing pins, but actually doesn&amp;#39;t matter
  NRF_SPIM3-&amp;gt;ENABLE = 0;               // disable SPI
  // Disconnect output drive, connect 1-wire rx/tx input to MISO
  NRF_SPIM3-&amp;gt;PSEL.MOSI = 0xFFFFFFFFUL; // MOSIPIN;
  NRF_GPIO-&amp;gt;PIN_CNF[MOSIPIN] = 0;      // input pin, input buffer connected, no pull, S0S1, sense disabled
  NRF_SPIM3-&amp;gt;PSEL.MISO = MOSIPIN;      // MISOPIN;
  NRF_SPIM3-&amp;gt;ENABLE = 7;               // enable SPI
  spi3wRXBuf[0] = 99; spi3wRXBuf[1] = 98;
  NRF_SPIM3-&amp;gt;TXD.PTR = NULL;
  NRF_SPIM3-&amp;gt;TXD.MAXCNT = 0;
  NRF_SPIM3-&amp;gt;RXD.PTR = (uint32_t)spi3wRXBuf;
  NRF_SPIM3-&amp;gt;RXD.MAXCNT = 1;
  NRF_SPIM3-&amp;gt;EVENTS_ENDRX = 0;
  NRF_SPIM3-&amp;gt;TASKS_START = 1;
  while(!NRF_SPIM3-&amp;gt;EVENTS_ENDRX);    // last byte received

  NRF_SPIM3-&amp;gt;TASKS_STOP = 1;
  while(!NRF_SPIM3-&amp;gt;EVENTS_STOPPED);
  NRF_GPIO-&amp;gt;OUTSET = 1 &amp;lt;&amp;lt; CSPIN;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This link give more details&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/68214/3-wire-spi-bi-directional-communication/295494#295494"&gt;3-wire-spi-bi-directional-communication&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>