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 know within the spi_master_send_receive() the select pin get pulled down, I also know its better not to configure the master.c file as well. This brings me to this question should I have the following for every time I wanna switvh between master devices? If not then how could I use the spi_master_send_receive() function while sending spi_master_0 as the argument and puling down the second select pin?

    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;
             spi_config.SPI_Pin_MISO = 28; 
             spi_config.SPI_Pin_MOSI = 25;
             spi_config.SPI_Pin_SS = 23; 
    }
    
        }
        break;
    
    
        default:
            break;
        }
    
Reply
  • I know within the spi_master_send_receive() the select pin get pulled down, I also know its better not to configure the master.c file as well. This brings me to this question should I have the following for every time I wanna switvh between master devices? If not then how could I use the spi_master_send_receive() function while sending spi_master_0 as the argument and puling down the second select pin?

    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;
             spi_config.SPI_Pin_MISO = 28; 
             spi_config.SPI_Pin_MOSI = 25;
             spi_config.SPI_Pin_SS = 23; 
    }
    
        }
        break;
    
    
        default:
            break;
        }
    
Children
No Data
Related