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

Cant drive pins with nrf_gpio_pin_setbut can using pullup/down.

Our new prototype uses an ISP1807 (nrf52840 module). The schematic is almost the same as a previous working prototype based on the Ublox Nina B302. (also nrf52840)

I've spent 2 days trying to understand what could be wrong and I'm not sure if this is a hardware or software problem. Or if my modules are somehow faulty. 

Using a brand new PCB that has had no other programming. 

  • I can drive pin 6 (NRF_GPIO_PIN_MAP(0, 26)) high and low using nrf_gpio_pin_set(26); This is my RED_LED
  • I can pull pins 2 and 4 high and low using the internal pullup / pulldown.
  • I cannot drive pins 2 or 4 high using nrf_gpio_pin_set  (pins 2 and 4 are my SCL and SDA pins for my sensors)

#define MY_RED_LED_PIN                  NRF_GPIO_PIN_MAP(0, 26)   
#define MY_SCL_PIN                      NRF_GPIO_PIN_MAP(0, 10)
#define MY_SDA_PIN                      NRF_GPIO_PIN_MAP(0, 9)

This code 

    for (int ii = 0; ii < 10000; ii++)
    {
        nrf_gpio_cfg(MY_SCL_PIN, 
                      NRF_GPIO_PIN_DIR_OUTPUT,
                      NRF_GPIO_PIN_INPUT_DISCONNECT,
                      NRF_GPIO_PIN_PULLUP,
                      NRF_GPIO_PIN_S0S1,
                      NRF_GPIO_PIN_NOSENSE);

        nrf_delay_ms(300);

        nrf_gpio_cfg(MY_SCL_PIN, 
                      NRF_GPIO_PIN_DIR_OUTPUT,
                      NRF_GPIO_PIN_INPUT_DISCONNECT,
                      NRF_GPIO_PIN_NOPULL,
                      NRF_GPIO_PIN_S0S1,
                      NRF_GPIO_PIN_NOSENSE);

        nrf_delay_ms(300);

        nrf_gpio_cfg(MY_SCL_PIN, 
                      NRF_GPIO_PIN_DIR_OUTPUT,
                      NRF_GPIO_PIN_INPUT_DISCONNECT,
                      NRF_GPIO_PIN_PULLDOWN,
                      NRF_GPIO_PIN_S0S1,
                      NRF_GPIO_PIN_NOSENSE);

        nrf_delay_ms(300);
    }

Looks like this

But this code 

    nrf_gpio_cfg(MY_SCL_PIN, 
                  NRF_GPIO_PIN_DIR_OUTPUT,
                  NRF_GPIO_PIN_INPUT_DISCONNECT,
                  NRF_GPIO_PIN_NOPULL,
                  NRF_GPIO_PIN_S0S1,
                  NRF_GPIO_PIN_NOSENSE);

    for (int ii = 0; ii < 10000; ii++)
    {
        nrf_gpio_pin_set(MY_SCL_PIN);

        nrf_delay_ms(100);

        nrf_gpio_pin_clear(MY_SCL_PIN);

        nrf_delay_ms(100);

    }

Shows this

I can flash the LED using this code

          nrf_gpio_cfg(MY_RED_LED_PIN, 
                    NRF_GPIO_PIN_DIR_OUTPUT,
                    NRF_GPIO_PIN_INPUT_DISCONNECT,
                    NRF_GPIO_PIN_NOPULL,
                    NRF_GPIO_PIN_S0S1,
                    NRF_GPIO_PIN_NOSENSE);

          nrf_gpio_pin_set(MY_RED_LED_PIN);
          nrf_delay_ms(300);
          nrf_gpio_pin_clear(MY_RED_LED_PIN);
          nrf_delay_ms(300);

I've checked the datasheet for the ISP1807 and I cannot see anything special about those pins. I've looked at the product spec for the NRF52840 and I cannot see anything (but maybe I've missed something).

I cannot understand why I can pull the pin high with the internal pull up, but I cannot set it high with nrf_gpio_pin_set.

Any suggestions are greatly appreciated.

Pins 2,4, 6 are at the bottom of this image.

Related