Skip to content

Wire / I2C doesn't work on STM32F4 #1355

@andrey-gvrd

Description

@andrey-gvrd

Describe the bug
The Wire library doesn't work.

I'm monitoring the SDA, SCL pins with a logic analyzer and there aren't even any transitions. Both stay pulled up by the pull-up resistors.

Same result with both 1.8 and 1.9 versions of the core.

Possibly related to: #463

To Reproduce
I've tried the following combinations:

Wire, I2C1: (PB7, PB6), (PB9, PB8), (PA10, PA9)
TwoWire, I2C2: (PB11, PB10), (PB14, PB13)

Using the following code to test the library:

#include <Wire.h>

TwoWire Wire2(PB14, PB13);

HardwareSerial HWSerial2(PA3, PA2);

void setup() {
  HWSerial2.begin(115200);
  //Wire.setSDA(PA10);
  //Wire.setSCL(PA9);
  //Wire.begin();
  Wire2.begin();
  HWSerial2.println("\nI2C Scanner");
}

void loop() {
  byte error, address;
  int nDevices;

  HWSerial2.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++) {
    Wire2.beginTransmission(address);
    error = Wire2.endTransmission();
    
    if (error == 0) {
      HWSerial2.print("I2C device found at address 0x");
      if (address < 16) 
        HWSerial2.print("0");
      HWSerial2.println(address, HEX);

      nDevices++;
    }
    else if (error == 4) {
      HWSerial2.print("Unknown error at address 0x");
      if (address < 16) 
        HWSerial2.print("0");
      HWSerial2.println(address, HEX);
    }    
  }
  if (nDevices == 0)
    HWSerial2.println("No I2C devices found");
  else
    HWSerial2.println("done");

  delay(1000);
}

Desktop:

  • OS: Windows 10
  • Arduino IDE version: 1.8.13
  • STM32 core version: 1.9
  • Upload method: STLink (STM32CubeProgrammer SWD)

Board:

  • Name: STM32F407G-DISC1

Additional context
Using VL53L3CX board from Pololu for the test, but I don't think it's important.

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