Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C Fails on STM32U585 and No Clock Signal #83550

Closed
DhaferAlzhrani opened this issue Jan 4, 2025 · 1 comment
Closed

I2C Fails on STM32U585 and No Clock Signal #83550

DhaferAlzhrani opened this issue Jan 4, 2025 · 1 comment
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32

Comments

@DhaferAlzhrani
Copy link

DhaferAlzhrani commented Jan 4, 2025

Describe the bug

When using I2C on the STM32U585 with Zephyr RTOS, the I2C communication fails with a TIMEOUT error during a write operation. The Logic Analyzer shows no activity on the clock line (SCL) and only a single pulse on the data line (SDA). The observed output is as follows:

Channel 0 (SCL): No activity.
Channel 1 (SDA): Single pulse.

Screenshot from 2025-01-04 02-18-45

To Reproduce

1.Configure the I2C1 peripheral in the device tree as follows:

config:

CONFIG_I2C_STM32_INTERRUPT=y
CONFIG_I2C=y
CONFIG_I2C_STM32=y
CONFIG_I2C_LOG_LEVEL_DBG=y
CONFIG_ASSERT=y

device tree:

&i2c1 {
    compatible = "st,stm32-i2c-v2";
    clock-frequency = <0x186a0>;  // 100 kHz
    #address-cells = <0x1>;
    #size-cells = <0x0>;
    reg = <0x40005400 0x400>;
    clocks = <&rcc 0x9c 0x200000>;
    interrupts = <0x37 0x0>, <0x38 0x0>;
    interrupt-names = "event", "error";
    status = "okay";
    pinctrl-0 = <&i2c1_sda_pb7 &i2c1_scl_pb6>;
    pinctrl-names = "default";
};
&pll1 {
    div-m = <1>;
    mul-n = <80>;
    div-q = <2>;
    div-r = <2>;
    clocks = <&clk_msis>;
    status = "okay";
};
&rcc {
    clocks = <&pll1>;
    clock-frequency = <DT_FREQ_M(160)>;  // 160 MHz
    ahb-prescaler = <1>;
    apb1-prescaler = <8>;  // 20 MHz
    apb2-prescaler = <8>;  // 20 MHz
    apb3-prescaler = <1>;
};

2.Ensure that PB6 (SCL) and PB7 (SDA) are properly routed and configured with pull-up resistors on board.

3.Execute a basic i2c_write operation in the application:

uint8_t data[] = {0x01, 0x42}; 
int ret = i2c_write(i2c_dev, data, sizeof(data), 0x48); 

4.Observe the system logs and the Logic Analyzer output.

Expected behavior
The I2C master should generate a complete sequence, including:
A Start Condition on SDA.
Clock pulses on SCL.
The slave address followed by data bytes.

Logs and console output

<dbg> i2c_ll_stm32_v2: stm32_i2c_msg_write: stm32_i2c_msg_write: TIMEOUT
I2C write error: -5

Environment:
MCU: STM32U585
Zephyr Version: 3.6.99

@DhaferAlzhrani DhaferAlzhrani added the bug The issue is a bug, or the PR is fixing a bug label Jan 4, 2025
Copy link

github-actions bot commented Jan 4, 2025

Hi @DhaferAlzhrani! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

4 participants