Skip to content

calling write_read with an empty write buffer repeatedly retries I2C reads #201

Closed
@TheButlah

Description

@TheButlah

With this code on an ESP32-C3:

i2c
  .write_read(ADDR_DOESNT_MATTER, &[], &mut [0; RECV_LEN_DOESNT_MATTER])
  .expect("Failed i2c");

I get this signal trace: repeated.zip

image

The code panics due to the NACK and then suspends execution in a loop inside my panic handler - I have triple checked this with both probe-rs and defmt logs. However, even though execution is suspended, the hardware I2C continues to send bogus I2C transmissions. So my only conclusion is that the registers that control the hardware I2C have been left in a state that repeatedly sends incorrect data.

Probably, it is due to this code in esp-hal:
image

The write command is issued, but the data to write is never actually set because bytes is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions