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.

  • I once used the bellow code and got some weird output for my SPI1 clock so I decided to allocate different clocks for each master. Meanwhile, Shouldn't I still define to instance of SPI like SPI0 & SPI1 for making a chip select or what is the other way to do it?

        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  = 29; // (I used the same clock)
            spi_config.SPI_Pin_MISO = 28;
            spi_config.SPI_Pin_MOSI = 25;
            spi_config.SPI_Pin_SS   = 23;
        }
        break;
        
        
        default:
            break;
        }
    

    Thank You

Reply
  • I once used the bellow code and got some weird output for my SPI1 clock so I decided to allocate different clocks for each master. Meanwhile, Shouldn't I still define to instance of SPI like SPI0 & SPI1 for making a chip select or what is the other way to do it?

        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  = 29; // (I used the same clock)
            spi_config.SPI_Pin_MISO = 28;
            spi_config.SPI_Pin_MOSI = 25;
            spi_config.SPI_Pin_SS   = 23;
        }
        break;
        
        
        default:
            break;
        }
    

    Thank You

Children
No Data
Related