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

Set SPI pins to tri-state

In one of our projects the nrf51 shares the SPI to a device with an STM32 microchip. To be able to successfully share the SPI channel, I'd have to put the SPI pins of the nrf51 into tri-state. I read that I could put them into tri-state by setting them as input. However, I don't know if it works, since I am still unable to make a successful connection to the device with the stm32 chip.

Is it possible to put a nrf51 pin into tristate and if so, how? Is there any way to test it if the pin really is in tri-state mode?

  • Hi

    You can put the SPI pins in the default configuration. This will set the pin in a high impedance mode. Set pin as input, disconnect input buffer, disconnect pull ups/downs, use standard drive, and disable pin sense mechanism. You can use nrf_gpio_cfg_default() which is defined as follow:

    __STATIC_INLINE void nrf_gpio_cfg_default(uint32_t pin_number)
    {
        nrf_gpio_cfg(
                pin_number,
                NRF_GPIO_PIN_DIR_INPUT,
                NRF_GPIO_PIN_INPUT_DISCONNECT,
                NRF_GPIO_PIN_NOPULL,
                NRF_GPIO_PIN_S0S1,
                NRF_GPIO_PIN_NOSENSE);
    }
    

    To test it you can try to connect the pin to VDD and measure any current flowing into the pin. In high impedance mode it should be less than 1uA.

Related