This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

change sda and scl pin for i2c1 on nrf5340

Hi,

I am using i2c driver available with zephr as i2c master. This is working fine.

I want to change the pins to P0.02 for SCL and P0.03 for SDA. I see multiple questions on similar line that indicates that this configuration should be possible.

However, when I try, the i2c transfer() call is getting stuck.

Since i2c driver from zephyr just binds to an existing i2c device, i am changing the sda and scl pin for i2c1 in "nrf5340pdk_nrf5340_cpuapp_common.dts" file. Let me know if i am missing any setting.

Regards,

Divya

 

Parents Reply Children
  • Hello, again!

    How does your prj.conf look? 

    The following are my I2C settings, see if yours match.

    prj.conf:

    # I2C
    CONFIG_I2C=y
    CONFIG_I2C_NRFX=y
    CONFIG_I2C_1=y
    CONFIG_NRFX_TWIM1=y
    
    CONFIG_NFCT_PINS_AS_GPIOS=y

    nrf5340pdk_nrf5340_cpuapp.overlay:

    &i2c1 {
    	status = "okay";
    	compatible = "nordic,nrf-twim";
    	sda-pin = <33>;
    	scl-pin = <34>;
    	clock-frequency = <I2C_BITRATE_STANDARD>; 
    };

    main.c (extract):

    void main(void)
    {
    	printk("The I2C test started\n");
        struct device *i2c_dev;
    	int error;
    
        i2c_dev = device_get_binding("I2C_1");
        if (!i2c_dev) {
            printk("Binding failed.");
            return;
        }
        i2c_configure(i2c_dev, I2C_SPEED_SET(I2C_SPEED_STANDARD));
        
    //(...) 
    }


    Best regards,
    Carl Richard

  • Hi Carl!

    You are correct. Everything is the same except for nrf5340pdk_nrf5340_cpuapp.overlay:

    &i2c1 {
    	status = "ok";
    	compatible = "nordic,nrf-twim";
    	sda-pin = < 3 >;
    	scl-pin = < 2 >;
        clock-frequency = <I2C_BITRATE_STANDARD>; 
    };

    Regards,

    Divya

  • Hello again!

    I miswrote when I said I got it to work with pins P0.02 and P0.02. The DK requires some modifications to support the NFC pins as conventional GPIOs, as described below:

    "Pins W1 and AA1 are by default configured to use the NFC antenna, but if they are needed as normal GPIOs, R43 and R46 must be NC and R42 and R45 must be shorted by 0R."

    This is described here

    Best regards,
    Carl Richard 

Related