Why 'pwm_set_dt(xxx, 0)' can not set gpio floating on NCS SDK 3.0.2 ?

For power cost down, use dts config  to set pwm gpio H0D1 as follow:

pwm1_default: pwm1_default {
group1 {
psels = <NRF_PSEL(PWM_OUT1, 0, 26)>;
nordic,drive-mode = <NRF_DRIVE_H0D1>;
};
};

1. When on NCS 2.4.1,  pwm func 'pwm_set_dt(xxx, 0)' can set gpio floating

2. When on NCS 3.0.2, 'pwm_set_dt(xxx, 0)' can NOT set gpio floating, because current get up 50 uA !

How can I use  'pwm_set_dt(xxx, 0)' set pwm gpio floating ?  and get current cost down?

Parents
  • Hi,

     

    The code will, in ncs v3.0.2, set the GPIO as output high or low, if the duty cycle is either 100 % or 0 %.

    If you are seeing 50 uA higher consumption than expected, it sounds like it is not the PWM itself that is causing this.

     

    Kind regards,

    Håkon

  • I find the key !

    Now I use demo ''v3.0.2\zephyr\samples\basic\blinky_pwm" to test the problem.  I found that if add CONFIG_I2C=y to the demo, the current cost will increase about 50uA, and if I let CONFIG_I2C=n, then the current down to normal. Could u explain the phenomenon and tell me how to get it ?

  • Hi,

     

    Q1: What is connected on your external board? Your current firmware does not set anything in a idle state, in terms of SDA/SCL.

    Q2: Do you have external pull resistors?

    Q3: Have you disabled serial via CONFIG_SERIAL=n?

     

    Kind regards,

    Håkon

  • Let me rephrase the que,our product requires PWM to drive the LED((P0.26 drive LED) and I2C to drive the Motion Sensor. However, on our product board(NCS 3.0.2), when we use pwm and I2C together, in idle state(use "pwm_set_dt(x,0)" to stop pwm), bottom current  is too high, about 50~60+uA. Our previous product was based on NCS 2.4.1,  I2C and PWM are used in the same way,but we did not find such an issue, bottom current  is less than 10uA.

    For trying to address issue, We did such tests:

    1. On product board(P0.26 drive LED), disconnect I2C pin(P0.03/P0.04) and sensor,  high bottom current exist. It means the current issue is not related to external circuits

    2. On product board(P0.26 drive LED), keep I2C pin disconnect, let CONFIG_I2C=n and delete all I2C application code(delete I2C init and other I2C ops), high bottom current disappear(bottom current  is about 5~6 uA).

    3. On DK board(as comparative experiment, P0.19 drive LED), use blinky_pwm to confirm, when add CONFIG_I2C=y, the issue can be reproduced.

    It seems just add CONFIG_I2C=y to project with pwm  function,  high bottom current issue will occurs.

  • A1:  firmware can enter low power state, I've make a reproduce demo(base on blinky_pwm and run on DK)  to illustrate this issue. if I send the demo to u? 

    A2: product board have, but  the result remains unchanged when remove external I2C circuit(sensor and pull up resistor). 

    A3: yes,have disabled. 

  • On DK board, use pwm to drive LED3, compare the different bottom current condition between CONFIG_I2C=y and CONFIG_I2C=n

    In overlay, config P0.19 to drive LED3:

    It seems CONFIG_I2C=y affect power cost of pwm pin ?

  • Hi,

     

    Setting CONFIG_I2C=y will cause an added current consumption due to the pins floating.

    Try adding a internal pull-up resistor and see if this helps with the current consumption.

     

    When running on nRF52-DK, with CONFIG_SERIAL=n, I see this current consumption.

    * CONFIG_I2C=n : ~0.3 mA

    * CONFIG_I2C=y : ~0.35 mA

    * CONFIG_I2C=y + SDA/SCL pin pull up: ~0.3 mA

    PS: PWM is active here.

    Please note that if I set pwm = 0 % or 100 %, I see < 10 uA.

     

    Here's the nrf52dk_nrf52832.overlay file with pull-up on SDA/SCL P0.26/P0.27:

    &pinctrl {
    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
    				<NRF_PSEL(TWIM_SCL, 0, 27)>;
    			bias-pull-up;
    		};
    	};
    };

     

    Please note that the I2C is now idle, and if started; you should use the pm_device API to set it to sleep/active state, similar to what is shown here:

    https://github.com/nrfconnect/sdk-zephyr/blob/ncs-v3.1.1/samples/sensor/apds9960/src/main.c#L80-L83

       

    Kind regards,

    Håkon

Reply
  • Hi,

     

    Setting CONFIG_I2C=y will cause an added current consumption due to the pins floating.

    Try adding a internal pull-up resistor and see if this helps with the current consumption.

     

    When running on nRF52-DK, with CONFIG_SERIAL=n, I see this current consumption.

    * CONFIG_I2C=n : ~0.3 mA

    * CONFIG_I2C=y : ~0.35 mA

    * CONFIG_I2C=y + SDA/SCL pin pull up: ~0.3 mA

    PS: PWM is active here.

    Please note that if I set pwm = 0 % or 100 %, I see < 10 uA.

     

    Here's the nrf52dk_nrf52832.overlay file with pull-up on SDA/SCL P0.26/P0.27:

    &pinctrl {
    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
    				<NRF_PSEL(TWIM_SCL, 0, 27)>;
    			bias-pull-up;
    		};
    	};
    };

     

    Please note that the I2C is now idle, and if started; you should use the pm_device API to set it to sleep/active state, similar to what is shown here:

    https://github.com/nrfconnect/sdk-zephyr/blob/ncs-v3.1.1/samples/sensor/apds9960/src/main.c#L80-L83

       

    Kind regards,

    Håkon

Children
Related