How to reassign LED pin values in NRF Connect SDK

I'm having trouble reassigning the pin value for the LED's in the connect SDK. I am using the base PWM Blinky example and have changed the pin value assigned to PWM_LED0 in the dts file but it does not reflect this during the debugging and still blinks LED 1 on the DK board. What is the proper way to change the pin assigned to PWM_LED0?

Parents
  • So I hadn't messed with PWMs before, but I think I figured something out. Also, I only have an nrf52840dk, so I'll show you what my devicetree looks like and you can relate it to your board.

    First is where the devicetree defines "pwmleds" and "pwm_led0":

    pwmleds {
    	compatible = "pwm-leds";
    	pwm_led0: pwm_led_0 {
    		pwms = < &pwm0 0x0 0x1312d00 0x1 >;
    	};
    };

    So that shows it pointing to "pwm0" node:

    pwm0: pwm@4001c000 {
    	compatible = "nordic,nrf-pwm";
    	reg = < 0x4001c000 0x1000 >;
    	interrupts = < 0x1c 0x1 >;
    	status = "okay";
    	label = "PWM_0";
    	#pwm-cells = < 0x3 >;
    	pinctrl-0 = < &pwm0_default >;
    	pinctrl-1 = < &pwm0_sleep >;
    	pinctrl-names = "default", "sleep";
    	phandle = < 0x19 >;
    };

    And then, "pinctrl-0" pointing to "pwm0_default" sounded enticing, so I looked at it:

    pwm0_default: pwm0_default {
    	phandle = < 0xd >;
    	group1 {
    		psels = < 0x16000e >;
    		nordic,invert;
    	};
    };

    Which looked strange. The psels point to "0x16000d". I made a devicetree overlay that redefined the psels in "pwm0_default" to 0x16000e and that started using the second LED. On my devkit, "led0" is pin 0xd and "led1" is 0xe. so it seems like you just need to add 0x160000 to whatever pin you want in the "psels" for "pwm0_default".

  • Just found a slightly friendlier way using the NRF_PSEL() function. Now my overlay looks like this to use led2:

    &pwm0_default {
        phandle = < 0xd >;
        group1 {
            psels = < NRF_PSEL(PWM_OUT0, 0, 0xf) >;
            nordic,invert;
        };
    };

Reply Children
No Data
Related