This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS 1.9.99: How to set sda and scl pins for I2C

With an earlier version of NCS  I could set the sda and scl pins using an overlay file:

boards/nrf52840dk_nrf52840.overlay:

&i2c0 {
    status = "okay";
    compatible = "nordic,nrf-twim";
    sda-pin = < 45 >;
    scl-pin = < 47 >;
    sht3xd@45 {
		compatible = "sensirion,sht3xd";
		reg = <0x45>;
		label = "SHT3XD";
		alert-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
	};
};

With NCS 1.9.99 I get this error:

In file included from /home/k/ncs1999/zephyr/include/zephyr/toolchain.h:50,
                 from /home/k/ncs1999/zephyr/include/zephyr/init.h:10,
                 from /home/k/ncs1999/zephyr/include/zephyr/device.h:29,
                 from /home/k/ncs1999/zephyr/include/zephyr/drivers/i2c.h:23,
                 from /home/k/ncs1999/zephyr/drivers/i2c/i2c_nrfx_twim.c:8:
/home/k/ncs1999/zephyr/include/zephyr/toolchain/gcc.h:77:36: error: static assertion failed: "/soc/i2c@40003000 has legacy *-pin properties defined although PINCTRL is enabled"
   77 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
      |                                    ^~~~~~~~~~~~~~
/home/k/ncs1999/zephyr/soc/arm/nordic_nrf/common/./soc_nrf_common.h:229:2: note: in expansion of macro 'BUILD_ASSERT'
  229 |  BUILD_ASSERT(!IS_ENABLED(CONFIG_PINCTRL) ||   \
      |  ^~~~~~~~~~~~
/home/k/ncs1999/zephyr/drivers/i2c/i2c_nrfx_twim.c:396:2: note: in expansion of macro 'NRF_DT_CHECK_PIN_ASSIGNMENTS'
  396 |  NRF_DT_CHECK_PIN_ASSIGNMENTS(I2C(idx), 1, scl_pin, sda_pin);        \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/k/ncs1999/zephyr/drivers/i2c/i2c_nrfx_twim.c:448:1: note: in expansion of macro 'I2C_NRFX_TWIM_DEVICE'
  448 | I2C_NRFX_TWIM_DEVICE(0);
      | ^~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.

How do I change the sda and scl pin assignments using NCS 1.9.99?

Thanks,

Jan Erik

Parents
  • Hi,

    The way pins are set has been changed for future releases, and this change is present on the devtag 1.9.99.

    Is there a reason that you are using 1.9.99, and not 1.9.1?
    On 1.9.1 you would not see these errors.

  • Hi,

    I'm developing an environmental control system using openthread and zephyr COAP. The system works but intermittently the openthread connection detaches, then becomes leader, but won't rejoin the existing network. This will be challenging to debug as I haven't found a way to trigger the problem. As a first step in trouble shooting I wanted to use more recent versions of the libraries to see if the problem persists. I chose 1.9.99 since it will have the most recent versions of zephyr, openthread, and COAP.

    As you point out, the way pins are set was changed to pinctrl. I was able to get the sht3xd example to compile with this overlay below but it doesn't connect with the device.  I'll see if my original problem is solved with v1.9.1

    &pinctrl {
       i2c0_default_alt: i2c0_default_alt {
          group1 {
             psels = <NRF_PSEL(TWIM_SDA, 0, 45)>,
                     <NRF_PSEL(TWIM_SCL, 0, 47)>;
          };
       };
       i2c0_sleep_alt: i2c0_sleep_alt {
          group1 {
             psels = <NRF_PSEL(TWIM_SDA, 0, 45)>,
                     <NRF_PSEL(TWIM_SCL, 0, 47)>;
             low-power-enable;
          };
       };
    };
    
    &i2c0 {
    	sht3xd@45 {
            status = "okay";
    		compatible = "sensirion,sht3xd";
            pinctrl-0 = <&i2c0_default_alt>;
            pinctrl-1 = <&i2c0_sleep_alt>;
            pinctrl-names = "default", "sleep";
    		reg = <0x45>;
    		label = "SHT3XD";
    		alert-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
    	};
    };

  • Try putting the pinctrl-* fields outside of the sht3xd block. If that doesn't work, there should be a file at build/zephyr/include/generated called devicetree_unfixed.dts. Attach that here with Insert->Image/video/file and I'll take a look.

    Ok, so that's why you are looking into 1.9.99, makes sense. Make a ticket specifically for the openthread issues if you are unable to solve them, and we will do our best to assist you.

Reply
  • Try putting the pinctrl-* fields outside of the sht3xd block. If that doesn't work, there should be a file at build/zephyr/include/generated called devicetree_unfixed.dts. Attach that here with Insert->Image/video/file and I'll take a look.

    Ok, so that's why you are looking into 1.9.99, makes sense. Make a ticket specifically for the openthread issues if you are unable to solve them, and we will do our best to assist you.

Children
No Data
Related