I2C pull-up

I'm trying to communicate with a ST MicroElectronics ST25R3918 NFC transceiver via I2C. 

I'm using a nrf52dk_nrf52832, NRF SDK 2.4.0 in vscode.

I want to use only external pull-up resistors on SDA and SCL (the ST chip  wants to run a 1MHz).

app.overlay has 

&i2c1 {

    status = "okay";
    pinctrl-0 = <&i2c1_default>;
    pinctrl-1 = <&i2c1_sleep>;
   pinctrl-names = "default", "sleep";
};
with pinctrl of 
i2c1_default: i2c1_default {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
                <NRF_PSEL(TWIM_SCL, 0,  29)>;
                   
        };
    };

    i2c1_sleep: i2c1_sleep {
        group1 {
            psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
                <NRF_PSEL(TWIM_SCL, 0, 29)>;
            low-power-enable;
        };
    };
I believe that the internal pull-ups (13.5K) are enabled, but I can't find the appropriate pinctrl statement to disable them.
Can you please point me in the right direction?
Parents
  • You need to add pin bias as mentioned in this documentation for the pinctrl. If you want no pull-ups then you need to disable bias like below

    &pinctrl {
    	i2c1_default: i2c1_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
    				<NRF_PSEL(TWIM_SCL, 0, 29)>;
    			bias-disable;
    		};
    	};
    
    	i2c1_sleep: i2c1_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
    				<NRF_PSEL(TWIM_SCL, 0, 29)>;
    			bias-disable;
    			low-power-enable;
    		};
    	};
    };
    
    &i2c0 {
    	status = "okay";
    	pinctrl-0 = <&i2c1_defaulti2c1_default>;
    	pinctrl-1 = <&i2c1_sleep>;
    	pinctrl-names = "default", "sleep";
    
    	wm8731: wm8731@1a {
    		compatible = "wolfson,wm8731";
    		reg = <0x1a>;
    	};
    };

    See here that I have added bias-disable to make sure that the pinctrl knows not to enable any pulls on the pins

  • When I add bias-disable; to app.overlay VSCODE complains  with "Property not mentioned in "nordic,nrf-pinctrl:child:child""

    Should I worry about this?

  • Hmm, I need to ask my colleague about this. It might be possible that the child node needs to support the default pin bias in the device tree. I look into this and come back to you with more info.

  • Hello Martin,

    We can see that these properties are defined in nordic,nrf-pinctrl

    If some property that is not there and is mentioned in the overlay then it would generate the error and the project would not compile.

    I recommend you to compile the project and check the output zephyr dts (./build/zephyr/zephyr.dts) and you should see the properties added / modified via the overlay over there.

    I also recommend you to check the respective registers. For example, in the below example, I am disabling the pull up/down for the I2C pins (P0.29 and P0.30).

    After compiling and flashing the code, I am reading the respective registers to see that the properties set in the overlay are reflected. I am reading the TWIM0 registers:

    reg 0x500: Twi is Enabled / Disabled (value 0x6 means Enabled)
    reg 0x508 and 50C: Pins configured (0x1D = 29, 0x1E=30)

    And then I am reading the GPIO registers for specific pins

    reg 0x71C and 0x720: for the pin#7 and 8, the value 0xC = b'1100 = PULL-UP

    reg 0x774 and 0x778: for the pin#29 and 30, the value is 0x600 (Pull Disabled)

    With regards,

    Naeem

Reply
  • Hello Martin,

    We can see that these properties are defined in nordic,nrf-pinctrl

    If some property that is not there and is mentioned in the overlay then it would generate the error and the project would not compile.

    I recommend you to compile the project and check the output zephyr dts (./build/zephyr/zephyr.dts) and you should see the properties added / modified via the overlay over there.

    I also recommend you to check the respective registers. For example, in the below example, I am disabling the pull up/down for the I2C pins (P0.29 and P0.30).

    After compiling and flashing the code, I am reading the respective registers to see that the properties set in the overlay are reflected. I am reading the TWIM0 registers:

    reg 0x500: Twi is Enabled / Disabled (value 0x6 means Enabled)
    reg 0x508 and 50C: Pins configured (0x1D = 29, 0x1E=30)

    And then I am reading the GPIO registers for specific pins

    reg 0x71C and 0x720: for the pin#7 and 8, the value 0xC = b'1100 = PULL-UP

    reg 0x774 and 0x778: for the pin#29 and 30, the value is 0x600 (Pull Disabled)

    With regards,

    Naeem

Children
  • Naeem,

    I tried several things to address this.

    I noticed that even when VSCode complains about 'bias-disable' (or for that matter 'bias-pull-up' ) my project still builds. But if I put 'bias-pull-x' in the pinctrl the build fails.

    I built the project three times. Once with no bias statement in pinctrl, once with bias-disable in pinctrl and once with bias-pull-up in pinctrl.

    After each build I flashed my board and listed the registers.

    Note that I am using I2C1 - my program uses SPI0.

    With no bias statement in pinctrl I get


    C:\Users\kover>nrfjprog --memrd 0x40004500
    0x40004500: 00000000 |....|
    C:\Users\kover>nrfjprog --memrd 0x40004508
    0x40004508: 0000001D |....|
    C:\Users\kover>nrfjprog --memrd 0x4000450c
    0x4000450C: 0000001E |....|
    C:\Users\kover>nrfjprog --memrd 0x40004524
    0x40004524: 06680000 |..h.|
    C:\Users\kover>nrfjprog --memrd 0x50000774
    0x50000774: 0000060D |....|
    C:\Users\kover>nrfjprog --memrd 0x50000778
    0x50000778: 0000060D |....|

    With a 'bias-disable' I get


    C:\Users\kover>nrfjprog --memrd 0x40004500
    0x40004500: 00000000 |....|
    C:\Users\kover>nrfjprog --memrd 0x40004508
    0x40004508: 0000001D |....|
    C:\Users\kover>nrfjprog --memrd 0x4000450c
    0x4000450C: 0000001E |....|
    C:\Users\kover>nrfjprog --memrd 0x40004524
    0x40004524: 06680000 |..h.|
    C:\Users\kover>nrfjprog --memrd 0x50000774
    0x50000774: 0000060D |....|
    C:\Users\kover>nrfjprog --memrd 0x50000778
    0x50000778: 0000060D |....|


    With a 'bias-pull-up' I get


    C:\Users\kover>nrfjprog --memrd 0x40004500
    0x40004500: 00000000 |....|
    C:\Users\kover>nrfjprog --memrd 0x40004508
    0x40004508: 0000001D |....|
    C:\Users\kover>nrfjprog --memrd 0x4000450c
    0x4000450C: 0000001E |....|
    C:\Users\kover>nrfjprog --memrd 0x40004524
    0x40004524: 06680000 |..h.|
    C:\Users\kover>nrfjprog --memrd 0x50000774
    0x50000774: 0000060C |....|
    C:\Users\kover>nrfjprog --memrd 0x50000778
    0x50000778: 0000060C |....|

    My results don't match yours. at 0x00004500, 0x40004524, ox50000774and 0x50000778  

    The differences at 0x40004524 are probably because I'm doing a err=i2c_configure(i2c1,I2C_SPEED_SET(I2C_SPEED_FAST));
    The value however does not match what I see in the nRF52832 Product Specification.for 400kHZ.

    The values at 0x50000774 and 0X50000778 are the most confusing.
    They are the same for compiling with a bias statement and with a 'bias-disable'.
    This seems consistent with the Zephyr documentation which says
    "bias-disable: Disable pull-up/down (default behavior, not required)."

    And changes when I use 'bias-pull-up'.

    But I don't understand the values at all.

  • Hello

    Is there any progress on this?

    KentOverton said:
    C:\Users\kover>nrfjprog --memrd 0x40004500
    0x40004500: 00000000 |....|

    This means the device is not enabled.

Related