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

nRF51822 SPI slave CSN

I'm using the nRF51822 as SPI slave. My CSN is of wrong polarity (active high). Is it possible to change the settings in spi_slave.c to make it work anyway?

  • Hi,

    Unfortunately, it is not possible to change the polarity of the CSN line in the SPIS module. You could try one of these options:

    • Use an external inverter on the CSN line.
    • Use two additional GPIOs to emulate an inverted CSN line in firmware.

    You can setup GPIOTE channel or PORT event, port event does not require 16M, so it's more power efficient with the "CSN manipulation". Setup GPIO x with SENSE_HIGH interrupt, GPIO y as output, and GPIO z as the SPIS CSN line. GPIO y and GPIO z must be connected on your PCB.

    When the external CSN goes high, it will trigger a GPIOTE event (PORT or using a channel). In the GPIOTE event, you set GPIO y to '0' and it will again trigger the SPIS CSN line.

    When the transaction is finished (master CSN is inactive), set GPIO y to '1' again.

    Best regards, Håkon

Related