Skip to content

First write on I2C bus never NACK's #132

@barafael

Description

@barafael

Problem:

When performing the first write transaction of the i2c scanner example, there is never a NACK, even if no device is attached on the bus.

Hardware required:

1x STM32F072 Nucleo

2x appropriate (for example 4.7KOhm) pullup resistor (alternatively, use any known OK I2C breakout board with a known I2C address which already includes pullups)

1x https://github.com/stm32-rs/stm32f0xx-hal/blob/master/examples/i2c_find_address.rs (for easier pin access, you may want to change the SDA pin to be PB9 instead of PB7)

Steps to reproduce:

  1. Wire up the pull up resistors from SCL/SDA to 3v3.

  2. Run the i2c scanner example: https://github.com/stm32-rs/stm32f0xx-hal/blob/master/examples/i2c_find_address.rs

  • Expected: _devices == 0
  • Actual: _devices == 1, ACK at address 0
  • If you see a lot of ACKs, your pull-ups could be wrong
  1. Change start address in line 32:
    for add in 0..=127 {
    to e.g. 6 and re-run the scan.
  • Expected: _devices == 0
  • Actual: _devices == 1, ACK at address e.g. 6
  1. Before the scan loop, add this line: let _ = i2c.write(0x4, &[]); and re-run the scan.
  • Expected: _devices == 0
  • Actual: _devices == 0 (yay!)
  1. (Optional) Remove the line added in step 4. Attach an I2C sensor with known address to the bus and re-run the scan.
  • Expected: _devices == 1
  • Actual: _devices == 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions