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

Thread NCP SPI pin configuration

I can not find where to change the default pins to connect the nrf52840 to the rpi over SPI.

The default pins are

SPI pin     Raspberry Pi pin     nRF52833, nRF52840 or nRF52811 pin
MOSI     pin 19 (GPIO10)     P0.04
MISO     pin 21 (GPIO09)     P0.28
SCK     pin 23 (GPIO11)     P0.03
CSN     pin 26 (GPIO07)     P0.29
INT     pin 40 (GPIO21)     P0.30

In the infocenter sais "The SPI pins on the Development Kit (nRF52833, nRF52840 or nRF52811) can be configured when building the example. " but i can not find where are they configured.

Please help

  • I figured that you need also to set the SPI_INT_GPIO_PIN in wpantund init config script found in /etc/init.d/wpantund for the GPIO to be initialized correctly. Did you modify this as well, or only the /etc/wpantund.conf file? I tested with GPIO20, and this seems to work correctly. Note that some GPIOs may collide with the NFC shield used by the MeshCop example for commissioning. From the schematics of the shield, it can look like GPIO25 is used for switching between SPI and I2C mode. 

    gpio25 is also listed in /sys/class/gpio, which may indicate that it is used by another module. I can't find any references to this the BR image, but a grep tells me that it found a match for "/sys/class/gpio/export" inside a few binary files:

    pi@raspberrypi:~ $ grep -r "/sys/class/gpio/export" / 2> /dev/null
    Binary file /proc/11933/task/11933/cmdline matches
    Binary file /proc/11933/cmdline matches
    /etc/init.d/wpantund:        echo "$SPI_INT_GPIO_PIN" > /sys/class/gpio/export
    Binary file /usr/sbin/nfccommissiond matches
    Binary file /usr/sbin/MQTT-SNGateway matches
    Binary file /usr/sbin/MQTT-SNLogmonitor matches
    Binary file /usr/lib/python2.7/dist-packages/RPi/_GPIO.arm-linux-gnueabihf.so matches
    

  • It seems that the pin I want to use is already in use:

    pi@raspberrypi:/sys/class/gpio $ ls
    export  gpio19  gpio23  gpio25  gpio6      gpiochip100  unexport
    gpio13  gpio21  gpio24  gpio26  gpiochip0  gpiochip504

    The NFC shield does not uses GPIO24 (pin 18):

    My schematic:

    I am going to try in a fresh Raspbian install, but it would be nice to know who is using those pins on the BR image.

  • Binary file /usr/sbin/MQTT-SNGateway matches <- This is the problem

    The MQTT-SN gateway uses GPIO 23, 24 and 25:

    github.com/.../Timer.h

    /*==========================================================
    * Light Indicators
    ===========================================================*/
    #define MAX_GPIO 27 // GPIO02 - GPIO27
    #define LIGHT_INDICATOR_GREEN 23 // RPi connector 16
    #define LIGHT_INDICATOR_RED 24 // RPi connector 18
    #define LIGHT_INDICATOR_BLUE 25 // RPi connector 22

Related