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

2 SPI Configurations sharing MOSI & MISO

Hello There, I want to connect two slaves to my nRF51422 PCA10028. I came up with the idea of using two master communications which share MOSI AND MISO but have different clocks and chip selects. I want to make sure that I can share the MISO and MOSI. Meanwhile, Is it another hard ware configuration for RX and TX buffers on different pins or that the only ones are 28 and 25?

Thank You

switch (spi_master_instance)
    {
        
        case SPI_MASTER_0:
        {
            spi_config.SPI_Pin_SCK  = 29;
            spi_config.SPI_Pin_MISO = 28;
            spi_config.SPI_Pin_MOSI = 25;
            spi_config.SPI_Pin_SS   = 24;
        }
        break;
				
			  case SPI_MASTER_1:
        {
            spi_config.SPI_Pin_SCK  = 27;
            spi_config.SPI_Pin_MISO = 28;
            spi_config.SPI_Pin_MOSI = 25;
            spi_config.SPI_Pin_SS   = 23;
        }
        break;
        

        default:
            break;
    }
Parents
  • @Milad: I don't really understand why you want to have 2 masters. You can have one master and several slave. Just have to use the SS (Slave Select) pins to control which one should be active. It's described in this figure.

    You can use any GPIO pin as MOSI, MISO etc.

  • @Milad: Please answer my question:

    Do you need to communicate with 2 SPI slaves at the same time ?

    Or you can talk them by turn ? Read/write SPI slave 1 and when you finish you can start to read/write SPI slave 2 ?

    If you need to communicate with 2 SPI slaves at the same time, then you need to have 2 SPI master instance and you only need to define the hardware once. BUT you can't use the same SCK, and MISO for both of them as shown in your code.

    If you don't need to talk to 2 slaves at the same time, and they can take turn then you only configure ONE SPI master. And then you use the SS pins to control each of them. You change the SS pin everytime you want to switch between each slaves.

Reply
  • @Milad: Please answer my question:

    Do you need to communicate with 2 SPI slaves at the same time ?

    Or you can talk them by turn ? Read/write SPI slave 1 and when you finish you can start to read/write SPI slave 2 ?

    If you need to communicate with 2 SPI slaves at the same time, then you need to have 2 SPI master instance and you only need to define the hardware once. BUT you can't use the same SCK, and MISO for both of them as shown in your code.

    If you don't need to talk to 2 slaves at the same time, and they can take turn then you only configure ONE SPI master. And then you use the SS pins to control each of them. You change the SS pin everytime you want to switch between each slaves.

Children
No Data
Related