PWM led pin configuration

I have a custom nRF52840 based board with 2 LED's 

In the .dtsi they are defined as follows

pwm0_default: pwm0_default {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 29)>,
                    <NRF_PSEL(PWM_OUT1, 0, 31)>;
            nordic,invert;
        };
    };

    pwm0_sleep: pwm0_sleep {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 29)>,
                    <NRF_PSEL(PWM_OUT1, 0, 31)>;
            low-power-enable;
        };
    };
The .dts file references the pins as follows
pwmleds {
       
        compatible = "pwm-leds";
        pwm_led1_red: pwm_led_1 {
            // Second parameter is offset into the array defined in pinctrl.dtsi
            pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
            label = "RED_PWM_LED_1";
        };
        
        pwm_led2_blue: pwm_led_2 {
            pwms = <&pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
            label = "BLUE_PWM_LED_2";
        };
    };
In the code the pwm device is obtained from dts without errors
const struct device *  _led_pwm = device_get_binding(LED_PWM_DEV_NAME);
However when I try to call
led_set_brightness(_led_pwm, <0 or 1>, 100 ) API I get error -22
Any ideas why?
Here is the screenshot of the LED schematics


Perhaps the pins are not configured correctly ? I'm having trouble accessing individual pins within the structure outlined above
A sample would be great
Thank you
Parents Reply Children
Related