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 Reply
  • Not a pretty solution but this works.

    void pinOn(uint32_t pin) {
        // Set pin direction as input using DIRCLR register
        NRF_GPIO->DIRCLR = (1 << pin);
    
        NRF_GPIO->PIN_CNF[pin] = (NRF_GPIO_PIN_DIR_INPUT << GPIO_PIN_CNF_DIR_Pos)
                                   | (NRF_GPIO_PIN_INPUT_CONNECT << GPIO_PIN_CNF_INPUT_Pos)
                                   | (NRF_GPIO_PIN_PULLUP << GPIO_PIN_CNF_PULL_Pos)
                                   | (NRF_GPIO_PIN_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
                                   | (NRF_GPIO_PIN_NOSENSE << GPIO_PIN_CNF_SENSE_Pos);
    }
    
    void clearPin(uint32_t pin) {
        // Reset PIN_CNF register to default value
        NRF_GPIO->PIN_CNF[pin] = 0;  // All bits set to 0 (default state)
        
        // Clear direction (set as input - default state)
        NRF_GPIO->DIRCLR = (1 << pin);
        
        // Clear output value
        NRF_GPIO->OUTCLR = (1 << pin);
    }

Children
No Data
Related