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

Two SPI and one I2C master on nRF51

Hi,

I have a custom board someone designed with two SPI masters and one I2C master.  We're now trying to enable the second SPI master and I'm running into errors because you cannot enable SPI1 when TW1 is enabled.


So the simple question is can I use two SPI masters and one I2C master on the nRF51422 simultaneously?  I'm afraid I know my answer already :-/

Best,
Matt

Parents Reply
  • If you look into the source of nrf_drv_spi_init, you can see that the pins are configured with correct GPIO settings, the HAL function only set the correct pin number in the peripheral. You could configure the second set of GPIOs in your application, and set it in the peripheral using the HAL function, but you need to make sure the peripheral is not busy when doing this.

    Also note that you need to control SS pin manually in case of switching SPI pins (set it to NRF_DRV_SPI_PIN_NOT_USED in the config). This pin is controlled as a standard GPIO by the driver.

Children
  • Hi Jørgen,

    That makes sense, but I think my case is different because I want to do the following:

    1) Initialize SPI0, I2C1

    2) Uninitialize I2C1

    3) Initialize SPI1

    So instead of uninitializing/initializing SPI, I want to uninitialize the I2C1 instance and initialize a SPI1 instance.

    I've gotten through uninitializing I2C, but the issue with starting a second SPI is that my #defines in nrf_drv_config.h have SPI1_ENABLED = 0, so all the SPI driver indicies, interrupt settings, etc are not set up for SPI1.

    What's your recommendation for the cleanest way to transition from one to two SPI instances like this?

    Thanks!

    Matt

Related