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

SPI Multiple Masters

Hello, I am tryong to use to masters to communicate with two accelerometers. Q1_ I found the following image from Nordic's website that shows SPI0 pins but there is no indication for SPI1's pins . Can someone point this out to me? image description

Q2_ I am using the following code and so far Im getting the clock the MOSI and the Chip Select pins right. However my MISO is noisy for both slaves that I am using. What could be the problem beside the connections? Thank You

static void spi_master_init(spi_master_hw_instance_t   spi_master_instance,
                            spi_master_event_handler_t spi_master_event_handler,
                            const bool                 lsb)
{
    uint32_t err_code = NRF_SUCCESS;

    switch (spi_master_instance)
    {
        
        case SPI_MASTER_0:
        {
					  spi_master_config_t spi_config0 = SPI_MASTER_INIT_DEFAULT;

            spi_config0.SPI_Pin_SCK  = 29;
            spi_config0.SPI_Pin_MISO = 28;
            spi_config0.SPI_Pin_MOSI = 25;
            spi_config0.SPI_Pin_SS   = 24;
					 spi_config0.SPI_CONFIG_ORDER = (lsb ? SPI_CONFIG_ORDER_LsbFirst : SPI_CONFIG_ORDER_MsbFirst);

    err_code = spi_master_open(spi_master_instance, &spi_config0);
    APP_ERROR_CHECK(err_code);

        }
        break;
				
				 case SPI_MASTER_1:
        {
						spi_master_config_t spi_config1 = SPI_MASTER_INIT_DEFAULT1;
            spi_config1.SPI_Pin_SCK  = 19;
            spi_config1.SPI_Pin_MISO = 28;
            spi_config1.SPI_Pin_MOSI = 25;
            spi_config1.SPI_Pin_SS   = 20;
					 spi_config1.SPI_CONFIG_ORDER = (lsb ? SPI_CONFIG_ORDER_LsbFirst : SPI_CONFIG_ORDER_MsbFirst);

    err_code = spi_master_open(spi_master_instance, &spi_config1);
    APP_ERROR_CHECK(err_code);

        }
        break;
        

        default:
            break;
    }

.....


int main(void)
{// @brief Function for main application entry.

    // Setup bsp module.
  bsp_configuration();
  spi_master_init(SPI_MASTER_0, spi_master_0_event_handler, false);
	spi_master_send_recv(SPI_MASTER_0, Powermode_Set, 2, m_rx_data_spi, 2);
		spi_master_send_recv(SPI_MASTER_0, Data_Format, 2, m_rx_data_spi, 2);

	//nrf_delay_ms(10);
  spi_master_init(SPI_MASTER_1, spi_master_1_event_handler, false);
	spi_master_send_recv(SPI_MASTER_1, Powermode_Set, 2, m_rx_data_spi, 2);
  spi_master_send_recv(SPI_MASTER_1, Data_Format, 2, m_rx_data_spi, 2);

	
	tx_DARA0=(0x80 | 0x32);//spi_master_close(SPI_MASTER_0);
  tx_DARA0=(tx_DARA0|0x40);

    for (;; )
    {
			
	
       // if (m_transfer_completed)
       // {
		 // spi_master_send_recv(SPI_MASTER_0, Device, 2, ID,2 );

			
		
		
	    
		  
			
		
			spi_master_send_recv(SPI_MASTER_0, &tx_DARA0, 1, m_rx_data_spi,8 );
			
			
			nrf_delay_ms(1);
			
			spi_master_send_recv(SPI_MASTER_1, &tx_DARA0, 1, m_rx_data_spi1,8 );
			
			nrf_delay_ms(1);


			
				
				
    }
}
Related