This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How many max SPI slave sensor I can connect with Nrf52840 via SPIM

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 etc

Sensors are LSM6DSL

I have five sensors connected via SPIM0 to nordic nrf52840. I am only able to get the reading from 1 or 2 sensors only which is connected closely to nordic. Is there any max limit with the current SPIM hardware and software limitations in terms of max slaves?

ALso, How to change the CS duration and RX delay timing of the SPIM hardware using the SDK 14?

Thank you

  • 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.

  • 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

  • SPI and UART are two different data interfaces and two different drivers. So I'm confused what exactly you are trying to do here. Are you using UART or SPI?

    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.

  • 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.

  • Ok, well there is no official UART Tx pin. GPIOs can be assigned as you see fit. I wouldn'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.

Related