no device npm1300_ek (one button sample) with nRF52 DK on I2C Bus

I try to get the one button sample to work. There were several details missing to be able to compile and run this sample, which was very frustrating. After editing/updating the

prj.conf: CONFIG_I2C=y

CMakeLists.txt: set(SHIELD npm1300_ek)

nrf52dk_nrf52832.overlay:

 #include <zephyr/dt-bindings/pinctrl/nrf-pinctrl.h>

 &i2c1 {
 status = "okay";
 pinctrl-0 = <&i2c1_default>;
 pinctrl-1 = <&i2c1_sleep>;
 pinctrl-names = "default", "sleep";
 clock-frequency = <I2C_BITRATE_STANDARD>; 
 //clock-frequency = <10000>;
 };
 
 &i2c1_default {
 group1 {
 psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
 <NRF_PSEL(TWIM_SCL, 0, 27)>;
 bias-pull-up;
 };
};

&i2c1_sleep {
 group1 {
 psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
 <NRF_PSEL(TWIM_SCL, 0, 27)>;
 low-power-enable;
 };
};

My zephyr.dts i2c1 snippet:

/* node '/soc/i2c@40004000' defined in zephyr/dts/arm/nordic/nrf52832.dtsi:172 */
		i2c1: i2c@40004000 {
			#address-cells = < 0x1 >;      /* in zephyr/dts/arm/nordic/nrf52832.dtsi:181 */
			#size-cells = < 0x0 >;         /* in zephyr/dts/arm/nordic/nrf52832.dtsi:182 */
			reg = < 0x40004000 0x1000 >;   /* in zephyr/dts/arm/nordic/nrf52832.dtsi:183 */
			interrupts = < 0x4 0x1 >;      /* in zephyr/dts/arm/nordic/nrf52832.dtsi:184 */
			easydma-maxcnt-bits = < 0x8 >; /* in zephyr/dts/arm/nordic/nrf52832.dtsi:185 */
			zephyr,pm-device-runtime-auto; /* in zephyr/dts/arm/nordic/nrf52832.dtsi:187 */
			compatible = "nordic,nrf-twi"; /* in zephyr/boards/nordic/nrf52dk/nrf52dk_nrf52832.dts:188 */
			status = "okay";               /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/npm13xx_one_button/build/npm13xx_one_button/zephyr/boards/nrf52dk_nrf52832.overlay:9 */
			pinctrl-0 = < &i2c1_default >; /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/npm13xx_one_button/build/npm13xx_one_button/zephyr/boards/nrf52dk_nrf52832.overlay:10 */
			pinctrl-1 = < &i2c1_sleep >;   /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/npm13xx_one_button/build/npm13xx_one_button/zephyr/boards/nrf52dk_nrf52832.overlay:11 */
			pinctrl-names = "default",
			                "sleep";       /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/npm13xx_one_button/build/npm13xx_one_button/zephyr/boards/nrf52dk_nrf52832.overlay:12 */
			clock-frequency = < 0x186a0 >; /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/npm13xx_one_button/build/npm13xx_one_button/zephyr/boards/nrf52dk_nrf52832.overlay:13 */
		};

with claudes assistance/support i got it to compile and run. But an i2c scan i2c0 shows no device at all.

What minimal required steps/configuration have to setup to get I2C enabled and detect devices on the bus should be?

Trying with the nrf-connect (Ubuntu) Linux-Desktop app (2x USB -C, 1x LiPo Battery) i get NPM detected, the LiPo Battery to and can change parameters for ex. the LED's live, so the BOARD is working.

Any support/hint/help is appreciated.

Parents Reply
  • Hi,

     

    Good, this means that the setup is working with the precompiled .hex that I shared.

    Then I suspect the issue is how your firmware is setup, ie. built.

     

    Try to delete your build folder, do not add any specific overlays or .conf files; and only set the SHIELD parameter, similar to this:

     

    Since we cannot overload the west cmd switch here, we just set the EK directly in CMakeLists.txt:

    # Copyright (c) 2023 Nordic Semiconductor ASA
    # SPDX-License-Identifier: Apache-2.0
    
    cmake_minimum_required(VERSION 3.20.0)
    
    set(EXTRA_DTC_OVERLAY_FILE npm1300.overlay)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    
    project(npm13xx_ek)
    target_sources(app PRIVATE src/main.c)

     

    Kind regards,

    Håkon

Children
  • Hi, build/compiling works with that setup. Situation stays, only the LED2 (amber) is blinking. despite turning on all 3 LEDs.

    "led_off(leds, 2U);"

    works. disabling it makes the LED2 light up constantly. Strange.

    #include <dt-bindings/regulator/npm13xx.h>
    
    &npm1300_ek_ldo1 {
    	regulator-initial-mode = <NPM13XX_LDSW_MODE_LDSW>;
    };
    
    &npm1300_ek_pmic {
    	host-int-gpios = <&gpio0 4 0>;
    	pmic-int-pin = <3>;
    
    	/*
    	npm1300_ek_leds: leds {
    		compatible = "nordic,npm1300-led";
    		status="okay";
    		//nordic,led0-mode = "error";
    		//nordic,led1-mode = "charging";
    		nordic,led0-mode = "host";
    		nordic,led1-mode = "host";
    		nordic,led2-mode = "host";
    	};*/
    };
    
    &npm1300_ek_leds {
    		compatible = "nordic,npm1300-led";
    		status="okay";
    		//nordic,led0-mode = "error";
    		//nordic,led1-mode = "charging";
    		nordic,led0-mode = "host";
    		nordic,led1-mode = "host";
    		nordic,led2-mode = "host";
    	};

    See the C-code and my npm1300.overlay attached.

    Additional, with USB-C in USB PMIC and without Battery the LED1 "CHG" is constantly on. Adding a battery, led1 turns off.

  • Hi,

     

    Can you please share your full project, including your build-folder?

    Based on your description, it sounds like you have not overridden the default led setup of the EK.

     

    Kind regards,

    Håkon

  • Hi,

     

    Build shows:

    				npm1300_ek_leds: leds {
    					compatible = "nordic,npm1300-led"; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:69 */
    					nordic,led0-mode = "error";        /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:70 */
    					nordic,led1-mode = "charging";     /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:71 */
    					nordic,led2-mode = "host";         /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:72 */
    				};

    but I cannot see that your overlay includes this sequence either?

     

    &npm1300_ek_leds {
    		compatible = "nordic,npm1300-led";
    		status="okay";
    		//nordic,led0-mode = "error";
    		//nordic,led1-mode = "charging";
    		nordic,led0-mode = "host";
    		nordic,led1-mode = "host";
    		nordic,led2-mode = "host";
    	};

     

    Try deleting your build folder, adding the sequence to npm1300.overlay, and remember to add this as an extra DTC overlay file when configuring your build.

     

    Afterwards, go into build-folder/application-name/zephyr/zephyr.dts and check that it is set as intended:

    				/* node '/soc/i2c@40003000/pmic@6b/leds' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:68 */
    				npm1300_ek_leds: leds {
    					compatible = "nordic,npm1300-led"; /* in ../../Users/hkn/Downloads/npm13xx_one_button/build2/npm13xx_one_button/zephyr/npm1300.overlay:61 */
    					status = "okay";                   /* in ../../Users/hkn/Downloads/npm13xx_one_button/build2/npm13xx_one_button/zephyr/npm1300.overlay:62 */
    					nordic,led0-mode = "host";         /* in ../../Users/hkn/Downloads/npm13xx_one_button/build2/npm13xx_one_button/zephyr/npm1300.overlay:65 */
    					nordic,led1-mode = "host";         /* in ../../Users/hkn/Downloads/npm13xx_one_button/build2/npm13xx_one_button/zephyr/npm1300.overlay:66 */
    					nordic,led2-mode = "host";         /* in ../../Users/hkn/Downloads/npm13xx_one_button/build2/npm13xx_one_button/zephyr/npm1300.overlay:67 */
    				};

     

    Kind regards,

    Håkon

  • Hi, the npm1300.overlay already was configured with the only-"Host" sequence.

    After deleting the build folder and doing a pristine build the zephyr shows this for the pmic@6b:

    			/* node '/soc/i2c@40003000/pmic@6b' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:10 */
    			npm1300_ek_pmic: pmic@6b {
    				compatible = "nordic,npm1300";       /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:11 */
    				reg = < 0x6b >;                      /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:12 */
    				host-int-gpios = < &gpio0 0x4 0x0 >; /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:14 */
    				pmic-int-pin = < 0x3 >;              /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:15 */
    
    				/* node '/soc/i2c@40003000/pmic@6b/gpio-controller' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:14 */
    				npm1300_ek_gpio: gpio-controller {
    					compatible = "nordic,npm1300-gpio"; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:15 */
    					gpio-controller;                    /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:16 */
    					#gpio-cells = < 0x2 >;              /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:17 */
    					ngpios = < 0x5 >;                   /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:18 */
    					phandle = < 0x7 >;                  /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:61 */
    				};
    
    				/* node '/soc/i2c@40003000/pmic@6b/regulators' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:21 */
    				npm1300_ek_regulators: regulators {
    					compatible = "nordic,npm1300-regulator"; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:22 */
    
    					/* node '/soc/i2c@40003000/pmic@6b/regulators/BUCK1' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:25 */
    					npm1300_ek_buck1: BUCK1 {
    						regulator-min-microvolt = < 0xf4240 >;  /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:26 */
    						regulator-max-microvolt = < 0x325aa0 >; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:27 */
    					};
    
    					/* node '/soc/i2c@40003000/pmic@6b/regulators/BUCK2' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:30 */
    					npm1300_ek_buck2: BUCK2 {
    						regulator-min-microvolt = < 0xf4240 >;  /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:31 */
    						regulator-max-microvolt = < 0x325aa0 >; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:32 */
    					};
    
    					/* node '/soc/i2c@40003000/pmic@6b/regulators/LDO1' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:35 */
    					npm1300_ek_ldo1: LDO1 {
    						regulator-min-microvolt = < 0xf4240 >;  /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:36 */
    						regulator-max-microvolt = < 0x325aa0 >; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:37 */
    						regulator-initial-mode = < 0x3 >;       /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:10 */
    					};
    
    					/* node '/soc/i2c@40003000/pmic@6b/regulators/LDO2' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:40 */
    					npm1300_ek_ldo2: LDO2 {
    						regulator-min-microvolt = < 0xf4240 >;  /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:41 */
    						regulator-max-microvolt = < 0x325aa0 >; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:42 */
    					};
    				};
    
    				/* node '/soc/i2c@40003000/pmic@6b/charger' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:46 */
    				npm1300_ek_charger: charger {
    					compatible = "nordic,npm1300-charger"; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:47 */
    					term-microvolt = < 0x3f52f0 >;         /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:48 */
    					term-warm-microvolt = < 0x3d0900 >;    /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:49 */
    					current-microamp = < 0x249f0 >;        /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:50 */
    					dischg-limit-microamp = < 0xf4240 >;   /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:51 */
    					vbus-limit-microamp = < 0x7a120 >;     /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:52 */
    					thermistor-ohms = < 0x2710 >;          /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:53 */
    					thermistor-beta = < 0xd34 >;           /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:54 */
    					charging-enable;                       /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:55 */
    				};
    
    				/* node '/soc/i2c@40003000/pmic@6b/buttons' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:58 */
    				npm1300_ek_buttons: buttons {
    					compatible = "gpio-keys"; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:59 */
    
    					/* node '/soc/i2c@40003000/pmic@6b/buttons/pmic_button_0' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:60 */
    					pmic_button0: pmic_button_0 {
    						gpios = < &npm1300_ek_gpio 0x0 0x0 >; /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:61 */
    						label = "Pmic button switch 0";       /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:62 */
    						zephyr,code = < 0xb >;                /* in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:63 */
    					};
    				};
    
    				/* node '/soc/i2c@40003000/pmic@6b/leds' defined in zephyr/boards/shields/npm1300_ek/npm1300_ek.overlay:67 */
    				npm1300_ek_leds: leds {
    					compatible = "nordic,npm1300-led"; /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:30 */
    					status = "okay";                   /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:31 */
    					nordic,led0-mode = "host";         /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:32 */
    					nordic,led1-mode = "host";         /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:33 */
    					nordic,led2-mode = "host";         /* in ../../../../mnt/df01dc22-f3bf-40d5-9858-752a58c9832d/devprojects/nordicsemi/intermediate/npm13xx_one_button/build/npm13xx_one_button/zephyr/npm1300.overlay:34 */
    				};
    			};

    But still only LED2 (Host) is blinking.

    Can you provide me your project instead of only the hex file? so i could check & compare what/why my project isn't working as intended.

Related