Matter Light Bulb Change Default LED1 Usage

Hi All,

I am using 'NRF SDK v2.7 + NRF5340 DK + VSCode' and cloned a official nrf 'matter light bulb' sample.

My question is the default 'matter light bulb' uses NRF5340 onboard LED1[p0.28] as various status and LED2[P0.29] as Light-Bulb[ON,OFF and Dimmable via PWM].

But I don't want to use this LED1 because I have to use it for some other purpose and want to map it to LED3[p0.30]. How can I free this LED1 as I cant find anywhere in code where I can make the changes.

Any idea how to:

- [1] Modify the overlay

- [2] Make the code changes

- [3] I cant find in code on how LED1 is being controlled in the light-bulb sample. Pardon me maybe I could be missing out

Please see my default nrf5340dk_nrf5340_cpuapp.overlay

/*
* Copyright (c) 2021-2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/dt-bindings/ipc_service/static_vrings.h>

/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
};

/*
* By default, PWM module is only configured for led0 (LED1 on the board).
* The light bulb app, however, uses LED2 to show the state of the lighting,
* including its brightness level.
*/
aliases {
pwm-led1 = &pwm_led1;
};

pwmleds {
compatible = "pwm-leds";
pwm_led1: pwm_led_1 {
pwms = < &pwm0 1 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
};
};
};

/* Set IPC thread priority to the highest value to not collide with other threads. */
&ipc0 {
zephyr,priority = <0 PRIO_COOP>;
};

&pwm0 {
pinctrl-0 = <&pwm0_default_alt>;
pinctrl-1 = <&pwm0_sleep_alt>;
pinctrl-names = "default", "sleep";
};

&pinctrl {
pwm0_default_alt: pwm0_default_alt {
group1 {
psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
nordic,invert;
};
};

pwm0_sleep_alt: pwm0_sleep_alt {
group1 {
psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
low-power-enable;
};
};
};

/* Disable unused peripherals to reduce power consumption */
&adc {
status = "disabled";
};
&i2c1 {
status = "disabled";
};
&spi2 {
status = "disabled";
};
&usbd {
status = "disabled";
};

Best Regards

Jacky Ortega

Parents Reply
  • Hi Jacky,

    In the Light bulb sample, the LED is controlled by the pwm0-device, which is set to LED1. If you change the following in your overlay

    &pinctrl {
    	pwm0_default_alt: pwm0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
    			nordic,invert;
    		};
    	};
    
    	pwm0_sleep_alt: pwm0_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT1, 0, 29)>;
    			low-power-enable;
    		};
    	};
    };

    to

    &pinctrl {
    	pwm0_default_alt: pwm0_default_alt {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT1, 0, 30)>;
    			nordic,invert;
    		};
    	};
    
    	pwm0_sleep_alt: pwm0_sleep_alt {
    		group1 {
    			psels = <NRF_PSEL(PWM_OUT1, 0, 30)>;
    			low-power-enable;
    		};
    	};
    };

    you should see that the pwm peripheral now generates a signal that drives P0.30 (LED3) instead of P0.29 (LED1)

    Kind regards,
    Andreas

Children
No Data
Related