nrf52840 dongle PCA10059 GPIO Out LED

I am trying to get an LED attached to GPIO to turn on. I have tried all documented methods I could find but with no success. I have no issue controlling the onboard LEDS but I cannot seem to configure a GPIO as an output. I also have no issue configuring a GPIO as an input. The LED 100% works as it lights if attached to VDD pin or when connected to a GPIO pin set as an input. My wiring for the LED is between the GND and GPIO pin (0.2) and i have tried using both set and clear but with no result. Any ideas would be greatly appreciated.

Parents
  • Hi,

    Which method did you try, and which pin have you conneced the LED to? Also, which SDK are you using?

    The simplest way to control a GPIO (which control the LED) is to just set it directly using nrf_gpio_pin_set() and nrf_gpio_pin_clear() with the pin number as parameter. For that you need "#include <hal/nrf_gpio.h>", and you need to first configure the pin as output using nrf_gpio_cfg_output(), with the pin number as parameter here as well.

  • yes that was the exact code i tried.

    #define LED_PIN NRF_GPIO_PIN_MAP(0,2)

    void led_setup(void)
    {
    ret_code_t err_code;

    // Configure the output pin
    nrf_gpio_cfg_output(LED_PIN);
    }

    void led_on(void) {
    nrf_gpio_pin_clear(LED_PIN);
    }

    void led_off(void) {
    nrf_gpio_pin_set(LED_PIN);
    }

    I am using SDK17.1.0. I have tried on other PINs as well. Also I am using a soft device in my main code but have tried with and without a soft device present

  • Hi,

    I see. This looks correct. Could it be that you are missing an include or similar - do you get warnings when building? Or can you share the full code?

    Also, if you have connected the LED to VDD for some time without a series resistor (if I read you correctly) you may have damaged it, so it is worth checking if it still works. Perhaps just measure the voltage on P0.02 to verify if you get it set and cleared correctly?

Reply
  • Hi,

    I see. This looks correct. Could it be that you are missing an include or similar - do you get warnings when building? Or can you share the full code?

    Also, if you have connected the LED to VDD for some time without a series resistor (if I read you correctly) you may have damaged it, so it is worth checking if it still works. Perhaps just measure the voltage on P0.02 to verify if you get it set and cleared correctly?

Children
Related