<?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 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19156/nrf52-as-spi-master-with-multiple-slaves</link><description>Hello, my project has 3 different devices (2 sensor and flash memory) on the same SPI bus all with their own CS. I ran across the following question , which has a response for a workaround for the NRF51. Upon jumping into the NRF52 SDK 12.2 documentation</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Apr 2021 06:46:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19156/nrf52-as-spi-master-with-multiple-slaves" /><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/305986?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 06:46:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:845f104f-406e-442e-a7c0-0727a013c0ef</guid><dc:creator>RixtronixLAB</dc:creator><description>&lt;p&gt;Which GPIO port do you use for MOSI,MISO and SCK ? I have like this :&lt;/p&gt;
&lt;p&gt;MISO = P 0.20&lt;/p&gt;
&lt;p&gt;MOSI = P 0.02&lt;/p&gt;
&lt;p&gt;SCK&amp;nbsp; = P 0.21&lt;/p&gt;
&lt;p&gt;CS = P 1.12&lt;/p&gt;
&lt;p&gt;CS_LCD = P 1.11&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Is it possible ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74153?ContentTypeID=1</link><pubDate>Thu, 13 Jul 2017 08:14:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db4e3c32-43c0-4972-97db-c5c4e38bbe08</guid><dc:creator>YASH</dc:creator><description>&lt;p&gt;What Should i write in case of nrf51422?
in place of
mw_spi_instance.drv_inst_idx
?
Please help, Thank you in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74152?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2017 23:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96ffc6b0-3447-4c7b-a5a8-357c2ec86767</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;I did the following to add this capability:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I moved the definition of spi_control_block_t from nrf_drv_spi.c to nrf_drv_spi.h,   just above the declaration of nrf_drv_spi_init&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Also added #include &amp;quot;nrf_drv_common.h&amp;quot;  to the top of nrf_drv_spi.h for compiling&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;This allows the spi_control_block_t  struct to be accessed my any source code that includes &amp;quot;nrf_drv_spi.h&amp;quot;.    Here is my CS change function:&lt;/p&gt;
&lt;p&gt;/*&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Function for changing Chip Selecti pins in the nRF52
*/&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;void spi_switch_chips( uint32_t chip_select )
{
volatile spi_control_block_t * my_setup = mw_spi_instance.drv_inst_idx;
my_setup-&amp;gt;ss_pin = chip_select;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; //A Slave select must be set as high before setting it as output,
 //because during connect it to the pin it causes glitches.
 nrf_gpio_pin_set(my_setup-&amp;gt;ss_pin);
 nrf_gpio_cfg_output(my_setup-&amp;gt;ss_pin);
 nrf_gpio_pin_set(my_setup-&amp;gt;ss_pin);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74151?ContentTypeID=1</link><pubDate>Tue, 24 Jan 2017 01:37:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70618f55-0984-43dd-8882-66f6c7288e97</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;@SRA&lt;/p&gt;
&lt;p&gt;Interesting point about star vs daisy chain (not sure if daisy chain is the correct term in this case, but I know what you mean)&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve only had issues with SPI on quite long wires to external displays when running very high speeds (36Mhz) - and that was just the MCU on one end and the display on the other.
I had to shorten the leads to the display, and also separate them, as the capacitance in the ribbon cable was causing crosstalk.&lt;/p&gt;
&lt;p&gt;BTW. I don&amp;#39;t think anyone has answered @TFETT&amp;#39;s last question about the time to reconfigure the SPI to a different speed each time.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d suggest that @TFETT look in the driver code for the SPI and see how much code is in the SPI config api call.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not an expert on the nRF51 hardware, but I know that other MCU&amp;#39;s etc STM32 have to completely shut down the SPI sub system and re-start it, if you want to change the clock speed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74150?ContentTypeID=1</link><pubDate>Tue, 24 Jan 2017 00:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cda31c5-0573-48bd-a575-10a3cf64a0e1</guid><dc:creator>SRA</dc:creator><description>&lt;p&gt;What everyone else wrote in your comments is good. If you can run mutliple busses, do so because you&amp;#39;ll have parallel access and avoid some traps with switching speeds and CS lines. If you absolutely must run multiple devices, that&amp;#39;s fine, just plan on not using the hardware CS line imo and come up with a CS_Changer(myDevice) to handle the SPI details. You may need to work around modes and speeds.&lt;/p&gt;
&lt;p&gt;On the multiple slaves, be careful of how you share the MOSI/MISO lines. You can get into a termination and reflection issue. I was surprised to find out how complex SPI to multiple devices can be, most people just hook it up and go, but to really do it right, can be a lot of work.&lt;/p&gt;
&lt;p&gt;If you can daisy chain is better and solves these termination issues, if you must star, do it as short as possible, consider a 22ohm resistor inline to each device off the MISO line if the total MISO length is long, keep the stubs as short as possible.&lt;/p&gt;
&lt;p&gt;Do it right, don&amp;#39;t overthink it too much. Plan on testing with a scope when you get a prototype up. Will only be an issue if you&amp;#39;re going to push these SPI devices as fast as they go.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74144?ContentTypeID=1</link><pubDate>Mon, 23 Jan 2017 18:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cf5c3f5-0158-49aa-b373-8dfd3f0ce84f</guid><dc:creator>TFETT</dc:creator><description>&lt;p&gt;I spoke to may layout person and it looks like 2 SPI buses is an option. It appears all the devices use the same mode, but varying speeds. With this change I will still need to have 2 slaves on a single SPI bus. As such when I transition between the slaves do I need to unint the driver and then reinit the driver? Is the overhead light or heavy between this transfer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74149?ContentTypeID=1</link><pubDate>Mon, 23 Jan 2017 02:53:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a98beb9-dbff-4890-adfb-b9dedf43f8d4</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;@TFETT&lt;/p&gt;
&lt;p&gt;You may find having 2 busses actually saves space, or saves via&amp;#39;s, so its best to speak to your layout person.&lt;/p&gt;
&lt;p&gt;But you&amp;#39;d still need a CS line for each device, so there is no saving there&lt;/p&gt;
&lt;p&gt;(Well most devices need a CS as part of their data comm&amp;#39;s for synchronisation of start of a new command)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74148?ContentTypeID=1</link><pubDate>Mon, 23 Jan 2017 02:15:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12544735-2c83-4417-b266-e4098e8041f0</guid><dc:creator>TFETT</dc:creator><description>&lt;p&gt;Thanks for the feedback @SRA &amp;amp; @Roger Clark. I&amp;#39;ll do an analysis of each device to better understand speeds and modes for each one. In general my design is very space constrained, thus the fewer buses means a simpler design. I will try to follow up with my layout resource and get her thoughts on the possible implications of adding another SPI bus. All the same this will still result in two slaves on one SPI bus.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74147?ContentTypeID=1</link><pubDate>Sun, 22 Jan 2017 20:43:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4350c743-d8a4-4f23-bbdf-372b57d11142</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;@SRA&lt;/p&gt;
&lt;p&gt;Good point about the differnt bus speeds whch may be needed. Also some devices need differnt SPI &amp;quot;mode&amp;quot; ( clock edge to data valid) but most peripherals seem to use the default mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74146?ContentTypeID=1</link><pubDate>Sun, 22 Jan 2017 16:51:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:baf11c4a-915b-4642-92fc-7218bedd45e0</guid><dc:creator>SRA</dc:creator><description>&lt;p&gt;I have a project like that on an STM32 and it was much easier to just use software control of the CS pin with a struct that stored all the pin and port info than it was to try and use the hardware CS pin moving around.&lt;/p&gt;
&lt;p&gt;Ill give another vote for using parallel SPINbusses if you can swing it. Esp of not all your SPI devices are the same speed and settings. My project I also change modes and bitrates all stored in that same struct, it works great but it was annoying to write. In my case I littersally didn&amp;#39;t have a single extra pin free though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 as SPI master with Multiple Slaves</title><link>https://devzone.nordicsemi.com/thread/74145?ContentTypeID=1</link><pubDate>Sat, 21 Jan 2017 06:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f420474b-eb50-48ba-ad5f-364b87f97707</guid><dc:creator>Roger Clark</dc:creator><description>&lt;p&gt;You may also want to consider putting at least 2 of them on different SPI pins. Because SPI is asynchronous, you could transfer to 2 devices at once, which would reduce the amount of time your processor has to be awake.&lt;/p&gt;
&lt;p&gt;I know the nRF51 does Not have hardware Chip select, so you are better off setting it to Not Connected in the SPI config struct and then controlling it via GPIO yourself.&lt;/p&gt;
&lt;p&gt;I did attend the nRF52 seminar and I recall the Chip Select question being asked (possibly my me), but I cant recall the answer with any certainty, I think it may still not be hardware CS on the 52, but you better wait fo a more definitive answer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>