SW PWM power consumption

Hi, I developed a solution using the pwm_nrf5_sw.

The accuracy is good enough, and I tested the power consumption using the PPK2 kit.

The average consumption is around 200uA, but the maximum consumption goes up to 480uA.
My question here is, should I ignore the maximum consumption and just focus on the average?

I added the consumption graph below.

  

Parents
  • Hi Ian,

    Which board are you trying this on? Is it a custom board?

    Best Regards,

    Priyanka

  • Is it possible to share the solution here so that I can try to reproduce this? Please do let me know in case you wish to set this ticket as private.

    -Priyanka

  • Hi, 

    Since I posted the original post, I managed to further optimise the consumption.

    But, since the consumption is so low, I assume I'm doing something wrong regarding the consumption measurements.

    So i cut the SB9, connected the board to PC (USB cable), PPK2 to PC (USB cable->DATA/POWER), VOUT to P22 (the upper nRF current measurement pin), and GND to External Supply - pin.

    The power switch on the nRF52DK is ON.
    I set the PPK2 to Source mode, enabled power output (3V), and uploaded the program to nRF.
    The output voltage of the pin is correct, but the consumption measurements are (as I understand) unexpectedly low. Could you confirm my measurement process is fine?

    Here is the code: 

    #include <zephyr/kernel.h>
    #include <zephyr/pm/pm.h>
    #include <zephyr/pm/policy.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/pwm.h>
    
    static const struct pwm_dt_spec pwm_led0 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));
    
    #define NUM_STEPS	50U
    #define SLEEP_MSEC	100U
    
    void main(void)
    {
    	uint32_t period = PWM_HZ(32);
    	uint32_t pulse_width = (uint32_t)(0.90*period);
    
    	int ret;
    	bool state = false;
    
    	printk("PWM-based LED fade\n");
    
    	if (!device_is_ready(pwm_led0.dev)) {
    		printk("Error: PWM device %s is not ready\n",
    		       pwm_led0.dev->name);
    		return;
    	}
    	ret = pwm_set_dt(&pwm_led0, period, pulse_width);
    	if (ret) {
    		printk("Error %d: failed to set pulse width\n", ret);
    		return;
    	}
    	const struct pm_state_info si = {PM_STATE_SUSPEND_TO_RAM, 0, 0};
    	pm_state_force(0, &si);
    }

    prj.conf:

    CONFIG_PWM=y
    CONFIG_PWM_NRF5_SW=y
    CONFIG_SERIAL=n
    and nrf52dk_nrf52832.overlay
    / {
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&sw_pwm 0 32 PWM_POLARITY_INVERTED>;
    		};
    	};
    };
    
    &sw_pwm {
    	status ="okay";
    	channel-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>,
    					<&gpio0 14 GPIO_ACTIVE_LOW>;
    	clock-prescaler = <0>;
    	generator = < &rtc0>;
    };
    The consumption levels:
Reply
  • Hi, 

    Since I posted the original post, I managed to further optimise the consumption.

    But, since the consumption is so low, I assume I'm doing something wrong regarding the consumption measurements.

    So i cut the SB9, connected the board to PC (USB cable), PPK2 to PC (USB cable->DATA/POWER), VOUT to P22 (the upper nRF current measurement pin), and GND to External Supply - pin.

    The power switch on the nRF52DK is ON.
    I set the PPK2 to Source mode, enabled power output (3V), and uploaded the program to nRF.
    The output voltage of the pin is correct, but the consumption measurements are (as I understand) unexpectedly low. Could you confirm my measurement process is fine?

    Here is the code: 

    #include <zephyr/kernel.h>
    #include <zephyr/pm/pm.h>
    #include <zephyr/pm/policy.h>
    #include <zephyr/sys/printk.h>
    #include <zephyr/device.h>
    #include <zephyr/drivers/pwm.h>
    
    static const struct pwm_dt_spec pwm_led0 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));
    
    #define NUM_STEPS	50U
    #define SLEEP_MSEC	100U
    
    void main(void)
    {
    	uint32_t period = PWM_HZ(32);
    	uint32_t pulse_width = (uint32_t)(0.90*period);
    
    	int ret;
    	bool state = false;
    
    	printk("PWM-based LED fade\n");
    
    	if (!device_is_ready(pwm_led0.dev)) {
    		printk("Error: PWM device %s is not ready\n",
    		       pwm_led0.dev->name);
    		return;
    	}
    	ret = pwm_set_dt(&pwm_led0, period, pulse_width);
    	if (ret) {
    		printk("Error %d: failed to set pulse width\n", ret);
    		return;
    	}
    	const struct pm_state_info si = {PM_STATE_SUSPEND_TO_RAM, 0, 0};
    	pm_state_force(0, &si);
    }

    prj.conf:

    CONFIG_PWM=y
    CONFIG_PWM_NRF5_SW=y
    CONFIG_SERIAL=n
    and nrf52dk_nrf52832.overlay
    / {
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&sw_pwm 0 32 PWM_POLARITY_INVERTED>;
    		};
    	};
    };
    
    &sw_pwm {
    	status ="okay";
    	channel-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>,
    					<&gpio0 14 GPIO_ACTIVE_LOW>;
    	clock-prescaler = <0>;
    	generator = < &rtc0>;
    };
    The consumption levels:
Children
  • Hi,

    Yes, the current consumption seems reasonable considering you using the RTC as the clock source. Note that the current drawn by the LED is not included in the measurement when you measure on the DK as the LEDs are supplied from a different power rail. 

    These lines can be omitted:

    const struct pm_state_info si = {PM_STATE_SUSPEND_TO_RAM, 0, 0};
    pm_state_force(0, &si);

    This call will not have any effect anyway as this power state is not implemented for the nRF5x chips. The chip will enter System ON mode when your program returns to the idle thread. 

    For expected power numbers in System ON, please refer to the "Sleep" section in the PS.

    Best regards,

    Vidar

Related