I2C

Title: Issue with I2C (TWI) Communication on nRF52840 (SDK 16, Segger 8.2a)

Description:

I am working with the nRF52840 using nRF SDK 16 in Segger Embedded Studio 8.2a. As I am new to the SDK, I started with an I2C (TWI) scanner code to detect my sensor (HTU with address 0x40). However, I am facing an issue where no devices are detected.

Observations & Debugging Attempts:

Hardware Setup:

I am using P0.26 for SDA and P0.27 for SCL.

I have verified the connections, and the sensor is powered correctly.

Oscilloscope Observations:

When probing the SDA and SCL lines, both remain at 3.3V (high state).

There is no clock signal on the SCL line, meaning communication is not being initiated.

Software Modifications & Issues:

Initially, I encountered an error related to vprintf, which was resolved by removing the related file.

The program now compiles and flashes successfully, but no devices are detected during scanning.

Questions:

Why is the SCL line not toggling?

Do I need to configure any additional settings in sdk_config.h or modify my TWI initialization?

Are external pull-up resistors required on the SDA and SCL lines for proper operation?

Is there anything else I should check to establish proper I2C communication?

Any guidance on resolving this issue would be greatly appreciated.

  • Hi,

    First of all I would like to mention that if you are new to the SDK and that means that you are starting new development now, I would advice using the nRF Connect SDK instead of the old nRF5 SDK. See nRF Connect SDK and nRF5 SDK statement.

    When probing the SDA and SCL lines, both remain at 3.3V (high state).

    Can you disconnect the sensor and meaure on the pins directly just to verify that there is not an issue externally?

    Why is the SCL line not toggling?

    Good question. Can you share how you configure the pins so that we see that the correct pins are used? Are you using a custom board or the DK? If custom board, could it be that there is a soldering or some other routing issue? Do you have logging showing relevant information, and have you for instance cheked what is happening with a debugger?

    Do I need to configure any additional settings in sdk_config.h or modify my TWI initialization?

    Internall pull resistors are normally enough for lower speeds, but for higher speeds external pull resistors may be needed. That should not be the main issu ehere though, as you report measuring a constant high voltage as I read it.

Related