<?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>How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29194/how-many-max-spi-slave-sensor-i-can-connect-with-nrf52840-via-spim</link><description>Hello Folks, 
 I am using PCA 10056 Eval board. I am using SPIM0 to connect 5 slave sensors. The Chip select is done by the UART Tx pin. So If I send 0x01 over UARt then the sensor- 1 will be selected. 
 UART Tx byte -- Sensor
0x01 -- 1
0x02 -- 2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 06 Jan 2018 01:36:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29194/how-many-max-spi-slave-sensor-i-can-connect-with-nrf52840-via-spim" /><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116086?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2018 01:36:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5f1bdbd9-a0ca-4993-9c56-6dd00b687f3e</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;If that&amp;#39;s actually the case, that after the UART byte has been clocked out fully then the chip needs 15us more before the output is ready (not that I see anything like that kind of delay on the spec sheet for the SLG46536V, it&amp;#39;s a few hundred nanos in most cases) then using a delay is fine. If the 15us is the time taken for the UART data to be sent, then a fixed delay is the wrong thing to use and you should poll/interrupt the UART to know when it&amp;#39;s finished sending. The latter is what I see more often than I&amp;#39;d like.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116085?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2018 01:25:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02cd4683-afcd-4e32-9b28-9c5e06c39ef9</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;I need to add delay lets say My uart is sending a byte and then after 15 micro second My CS pin is setting low. This is example. Now in this case after sending UART byte I have to wat for 15 micro seconds. How Am I going to wait if I dont use delay?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116084?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2018 00:59:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ea2dcc9-1def-4828-bf52-2d2cebabef7c</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;use nrf_delay() if you need a delay - the better question is why do you need a fixed delay? It&amp;#39;s almost always an indication of poor code which ought to be using interrupts and callbacks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116083?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2018 00:27:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de932778-4d9f-4e7b-a6c9-22b091f2bc06</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;SO How should I provide delay in my application if needed?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116082?ContentTypeID=1</link><pubDate>Sat, 06 Jan 2018 00:07:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05eb5afe-6f86-4d95-a3d6-5e810884b7e9</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;@Dave_Couling of course you can use nrf_delay() when using the softdevice. If the softdevice needs to interrupt you, it will interrupt you, there is no effect on timing. I don&amp;#39;t recommend using it in general because it stinks of bad synchronous code and I don&amp;#39;t recommend using it or any long-running piece of code which is running in an interrupt handler with higher priority than the softdevice low priority interrupt as that prevents the SD from cleaning up as fast as it likes, however it is not correct to say that nrf_delay() affects the softdevice timings, it absolutely does not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116087?ContentTypeID=1</link><pubDate>Fri, 05 Jan 2018 20:16:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98edb0a8-31ab-40b4-8110-63ea7ce2e358</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;Resolved the Issue. I changed the GPIO strength of the pins SCK and MISO from standard &amp;#39;0&amp;#39; , standard &amp;#39;1&amp;#39; to High drive &amp;#39;0&amp;#39; , high drive &amp;#39;1&amp;#39;. and I am able to see all the seven senors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116081?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 20:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55fb41fd-ed43-4f8d-a855-5cf2f2900e0d</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;I have seen in the scope that once I add more than 3 sensors on the SPI bus. Someone is pulling down MISO pin SO that is why I reading wrong value. I am reading 0x40 instead of correct value 0x6A.
Do you have any thoughts on this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116080?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 02:39:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a35d654-5fa8-45b3-87c8-01a2d59112a3</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;Sorry for the late reply. I have some images of the scope to show you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116079?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 01:08:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5900de85-f1af-40f5-af7f-1f0a8eea8d08</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Do you have a logic analyzer to verify your CS pin is switching correctly?   I really think even with properly coding you could still have timing issues.  SPI is sensitive to CS switching on/off at the correct number of clock cycles: &lt;a href="https://i.stack.imgur.com/58rQ6.jpg"&gt;i.stack.imgur.com/58rQ6.jpg&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;d also set your SPI baud rate to the lowest possible&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116078?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 01:03:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a899662c-e23c-4fe1-a971-f0e454375f8a</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;What should I use for the delay. Right now we are not using the softdevice. But in future we might. Mow I am debugging using the scope.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116077?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 01:00:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b706db4f-76c6-4ac4-84c1-40a018059063</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;never use nrf_delay()  called when you are running the SoftDevice.  It has bad affects on the bluetooth stack which is very time sensitive.&lt;/p&gt;
&lt;p&gt;Have you placed on oscilloscope the CS pins to verify it is switching properly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116076?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 00:50:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a079fc2f-a19c-48ab-acad-9a6592e4aff3</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;I have done that thing. I have included the UART driver in SPI code. So here what I am doing app_uart_put(0x01);
nrf_delay_ns(80);
SPI_transfer()
nrf_delay_ns(80);
App_uart_put(0x00) de-select.&lt;/p&gt;
&lt;p&gt;THis is working fine if I havge 2 or 3 sensors. Once I include more then 4, then those senors are not working. adding sensors also messed up the working sensor&amp;#39;s data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116075?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 00:46:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d45eaf4-27e0-48c7-b7db-f67d82ede385</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;This will vastly increase the complexity of your solution though.  Instead of letting the nRF52 driver control the CS pin(s) you are now using two independent drivers for this.  You will likely have alot of timing issues as a SPI interface is clocked based on the state of the CS chip.  Delays in enabling/disabling the CS can result in data corruption.  I&amp;#39;d recommend against this method is possible.&lt;/p&gt;
&lt;p&gt;If you have to use this solution you&amp;#39;ll have to re-write the SPI driver code for your application to include the UART control.  It will get a little messy but it should work.   Look at the nrf_drv_spi.c and nrf_drv_spi.h files in the /spi_master folder of the SDK.   Look at each section which sets/clears the CS pin.  Here is where you would have to set your UART-&amp;gt;CS commands.  This means you have to include the UART driver files and configure the module accordingly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116074?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 00:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5914d232-eb12-45fa-9ff2-87de22cc9b5f</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;Sorry from My side I am not able to explain my problem. I am not using UART to talk to the sensor. My sensor hardware has two chips one is LSM6DSL and SLG46536V. The SLG46536V is acting as a UART to GPIO converter. So if u send 0x01 over UART to SLG46536V, it will make one of the pins of SLG46536V to low and if you send 0x00 then it will make that pin high. So the output pin1 of the SLG46536V is connected to sensor 1. output pin2 of SLG46536V is connected to sensor2 and so on. We have max seven sensors. So all the sensor hardwares are having this one  SLG46536V and one LSM sensor. We are using SLG46536Vso that we do not need to use GPIOs of the controller.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116073?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2018 00:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b6574a3-9822-46bb-9878-ca7c98a88827</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;The LSM6DSL is a SPI or I2C device.  There is no UART functionality.  I believe you must be confused about what data interface you&amp;#39;re dealing with here.  This chip cannot transmit or receive via UART protocol.  Therefore you Master chip (nRF52) shouldn&amp;#39;t use UART either.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116072?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df238788-ad56-4ae2-86ae-76d37f13a913</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;Cool thank you for the reply. But the thing is with the different controller (freescale) we are able to connect 7 sensors over SPI using just single Chip select(UART transmit pin) We have a special chip in over sensor hardware which is receiving the UART data and asserting the CS for that sensor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116071?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:53:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f240fcc-4cbb-426c-ac34-000cac49fd28</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Definitely giving you issues!  These are two very separate drivers and protocols, do not mix.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116070?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:50:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3abb391a-9211-4cf9-9f3a-ca97da5fb300</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;YEs you are right there is no official UART Tx pin. But I configured a GPIO as UART so that is why I am saying the UART Tx pin. In this configuration where the UART is acting as the CS driver, do you thank I sould use separate GPIOs for chip select. Do you think using the UART driver for chip select is giving the issue. Or do you think there is a connection issue like the wires I am using are having some noise so that I am reading the wrong WHO_AM_I values for some sensors(btw if I connect each sensor individually then I am able to read the correct values)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116069?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:42:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5f6a070-ff63-49d5-8681-28c7d1210647</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Ok, well there is no official UART Tx pin.  GPIOs can be assigned as you see fit.  I wouldn&amp;#39;t use the UART driver to set your CS pins.  This will create issues with your UART and SPI Driver code.   When you initialize your SPI module you need to specify a CS pin.   If you wish to talk to multiple devices the best way is to uninit and re-init the SPI module with whatever CS pin you wish to talk to.  The SPI driver code in nrf_drv_spi.c will handle the CS pin selection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116068?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:31:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:471c03e3-3da2-4e76-ab78-d6ad88398fe9</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;Sorry for the confusion.  Lets say five sensors are connected with the SPI bus of the nordic. Each sensor is connected using MISO, MOSI and CSK. Now, for the cheap select, what I am doing is that I am using UART hardware. The UART Tx pin of NRF52840 is acting as CS for all the sensors. Each sensor is connected with the UART Tx pin. If I will send the 0x01 over the UART Tx pin then the sensor 1 will be selected. Its CS pin will go low. Now I will perform the data transfer over the SPI and send 0x00 over the UART Tx pin. Sending 0x00 will make the CS pin of that sensor to high. This is how my CS mechanism is working. I am not using dedicated GPIOs for the CS pins of all the sensors. Instead using just one UART TX pin to act as CS pin for the sensors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116067?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:26:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c98334de-16b5-4d5d-80a2-d95b520a43c3</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;SPI and UART are two different data interfaces and two different drivers.  So I&amp;#39;m confused what exactly you are trying to do here.   Are you using UART or SPI?&lt;/p&gt;
&lt;p&gt;NoteL  UART is NOT a bus protocol. Meaning its ONLY one device to one device.   SPI is a bus protocol so you can attached multiple devices on the data data lines.  HOWEVER you need a different CS pin/line assigned to each sensor device.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116066?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d604f8e5-5a3d-4b09-99d6-d496fa6122f3</guid><dc:creator>Chitrang Talaviya</dc:creator><description>&lt;p&gt;HEllo Dave, thank you for the answer. I am using the UART Tx as my chip select. I am not using any GPIOs as chip select. It is something like addressing kind of mechanism. I am using the Silego chip that reads the UART stream and assert a CS pin for that sensor. If you send 0x01 over UART TX then first sensor will be activated and so on. If you send any 0x00 over UART then that sensor will be de-selected&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How many max SPI slave sensor I can connect with Nrf52840 via SPIM</title><link>https://devzone.nordicsemi.com/thread/116065?ContentTypeID=1</link><pubDate>Tue, 02 Jan 2018 23:08:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47536ba2-733f-4bec-969b-eeef878980f5</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Have you written your own wrapper for handling the different CS pins for each device?   As far as I can tell, you should be limited really by the total number of CS pins you can control.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>