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

nRF52 spi0 pin mappings

Hi, I am trying to get the example spi slave working. I am using SDK 11.0 ( I will try again under the 12.0 SDK later today). I've checked my spi master by running the master in loopback mode and verifying that it does receive what is being sent. I also verified on a logic analyzer the state of the spi pins. This all seems correct. I get an initial invocation of the spi_event_handler when the peripheral is configured. Then no other events.

One thing that I don't understand is the convention for assigning pins to the MOSI, MISO etc. This post : devzone.nordicsemi.com/.../ has a response that the pin assignment follows gpio numbering. I have looked thru the nRF52 product specification and cannot find a mapping of the gpios. Is it possible to point me to the document (or header file ) that specifies the mapping of gpios to pin numbers

Another thing that puzzles me is that the header/pinout diagrams all seem to indicate that SPI0 is brought out on the header. But the spi slave example is using SPIS_INSTANCE =1 as the index. In reading thru the product specification it is not clear if there is a mapping of SPIS_INSTANCE(1) to the SPI0 peripheral and it's associated pins.

I did notice this morning that there is a difference between the latest SDK code and the SDK that I am currently using, so I will go back and attempt the SDK 12 version and see if I get different results

I have searched thru the examples and questions and I realize that there are a lot of questions related to SPI slave configuration ( so I apologize if the question is redundant).

Update : I installed the SDK12 and re-ran the SPI slave example. Same response. Next I compiled and ran the spi master example in loopback mode. The transfers complete, but all I get back is 0xff characters. The MOSI and MISO pins ( P0.23 & P0.24) are tied together. I also verified with an ohm meter that I have continuity on the cable that ties MISO and MOSI together.

Thanks Victor

Parents
  • The spi example is setup to work with the spis example. SPI0 is can be mapped to any pins on the nRF52 (on the nRF devices all gpio pins can have any digital function like spi, gpio, uart, twi etc, only analog function has to be used on certain pins). Both example uses these pins for spi (as you can see in sdk_config.h):

    #define SPI_SCK_PIN 3
    #define SPI_MISO_PIN 28
    #define SPI_MOSI_PIN 4
    #define SPI_SS_PIN 29
    

    Connect these pins on the two boards and it should work.

    Spi example uses the SPI0 peripheral (#define SPI_INSTANCE 0) while the spis example uses the SPIS1 peripheral (#define SPIS_INSTANCE 1).

Reply
  • The spi example is setup to work with the spis example. SPI0 is can be mapped to any pins on the nRF52 (on the nRF devices all gpio pins can have any digital function like spi, gpio, uart, twi etc, only analog function has to be used on certain pins). Both example uses these pins for spi (as you can see in sdk_config.h):

    #define SPI_SCK_PIN 3
    #define SPI_MISO_PIN 28
    #define SPI_MOSI_PIN 4
    #define SPI_SS_PIN 29
    

    Connect these pins on the two boards and it should work.

    Spi example uses the SPI0 peripheral (#define SPI_INSTANCE 0) while the spis example uses the SPIS1 peripheral (#define SPIS_INSTANCE 1).

Children
  • I can't used P.002 as MOSI pin on DK and on stand alone design do you know why ?

    is there a setting inside SDK_CONFIG.h for the analog module to use Vcc as VREF, by chance?

    similar to infocenter.nordicsemi.com/index.jsp

    Reference voltage.

    Following options are available:

    • 0 - Internal 1.2V
    • 1 - Internal 1.8V
    • 2 - Internal 2.4V
    • 4 - VDD
    • 7 - ARef
    Note
    This is an NRF_CONFIG macro.

    For my understanding "Often the analog module takes priority over everything else, but you can usually set up the ref pin to be either internal or external"

    // SPI_MOSI_PIN 2 GPIO / AIN0  DOES NOT WORK  AIN7 P31 OK
    // SPI_MISO_PIN 3 GPIO / AIN1 OK
    // SPI_SCK_PIN 4 GPIO / AIN2 OK
    // CHANNEL1_CS_PIN 9 GPIO  PROBABLY ON DK IT IS NFC
    // CHANNEL2_CS_PIN 7 GPIO OK

Related