This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Creating Two SPI instances for same slave

We are using NRF52832, SDK 11.0.0.2 alpha, S132 soft Device ,I need some clarifications on using SPI,

  1. In nrf52832 SPI Master driver is it possible to create two SPI instances for the same slave device.
  2. If Yes is it possible to configure the instance as one for DMA transactions(USE_EASY_DMA==1) and the other for normal SPI transactions(USE_EASY_DMA==0).
  • Are you going to use the same pins (MISO, MOSI, SCK, CS) for both SPI instances? If so it will most likely not work unless you always makes sure that the two instances doesn't use the pins at the same time. If you are not going to use the same pins, using two SPI instances for the same slave device is just fine.

  • Hi, Our intention is to do both DMA transaction and non-DMA transaction with one Slave device. We may use only one transaction at a time. In that case as you said, wont there be any issues ?

  • Hi, I tried creating two SPI instances SPI1 and SPIM2 for the same slave device connected to pins 11(SCLK), 12(MOSI), 13(MISO), 14(CS), done a 4 byte transaction with slave using SPI1 and it was success followed by 3 seconds delay I tried to do DMA transaction with the same slave but it was not success.

    The same code when I start the DMA transaction after I uninit the SPI instance created for CPU transaction then it is fine.

    In the above scenario I'm not using the SPI slave (data transaction) at the same time by using both instances. what would be the reason for this behaviour?

  • If they are using the same pins it is no surprise i doesn't work. When uninitializing the SPI instance it will free the pins used, such that the SPIM instance will be able to use them. Try to do this instead of uninit:

    NRF_SPI1->PSEL.MISO = (SPI_PSEL_MISO_PSELMISO_Disconnected << SPI_PSEL_MISO_PSELMISO_Pos);
    NRF_SPI1->PSEL.MOSI = (SPI_PSEL_MOSI_PSELMOSI_Disconnected << SPI_PSEL_MOSI_PSELMOSI_Pos);
    NRF_SPI1->PSEL.SCK = (SPI_PSEL_SCK_PSELSCK_Disconnected << SPI_PSEL_SCK_PSELSCK_Pos);
    

    You will ofcourse have to set them up again (and disconnect the SPIM2 pins) before using SPI1 again.

  • Can you please explain, what these lines will do ?

    NRF_SPI1->PSEL.MISO = (SPI_PSEL_MISO_PSELMISO_Disconnected << SPI_PSEL_MISO_PSELMISO_Pos); NRF_SPI1->PSEL.MOSI = (SPI_PSEL_MOSI_PSELMOSI_Disconnected << SPI_PSEL_MOSI_PSELMOSI_Pos); NRF_SPI1->PSEL.SCK = (SPI_PSEL_SCK_PSELSCK_Disconnected << SPI_PSEL_SCK_PSELSCK_Pos);

Related