Skip to content

I2C >> Bit Error when compiling for 160 MHz #6497

Closed
@detamend

Description

@detamend

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • I have filled out all fields below.

Platform

  • Hardware: Wemos D1 mini pro (ESP8266)
  • Core Version: 2.5.2
  • Development Env: Arduino IDE
  • Operating System: Windows 10 x64

Settings in IDE

  • Module: Wemos D1 mini pro
  • Flash Mode: not sure (using IDE)
  • Flash Size: 4MB
  • lwip Variant: v2 Higher Bandwidth
  • Reset Method: not sure
  • Flash Frequency: not sure (IDE)
  • CPU Frequency: 80Mhz AND 160MHz
  • Upload Using: SERIAL
  • Upload Speed: 115200

Problem Description

Trying to let two ESPs talk to each other via I2C - easy, right? Obviosly not, when boths CPUs running at 160 MHZ.

SENDER SKETCH

#include <Wire.h>

#define SDA_PIN 4
#define SCL_PIN 5

#define sender 0x42
#define reciver 0x08

void setup(){
  Serial.begin(115200);
  Wire.begin(SDA_PIN,SCL_PIN,sender);
}

void loop(){
  Wire.beginTransmission(reciver);
  Wire.write("aaAA");
  Wire.endTransmission();
  delay(1000);
}

RECIVER SKETCH

#include <Wire.h>

#define SDA_PIN 4
#define SCL_PIN 5

#define sender 0x42
#define reciver 0x08

void setup(){
  Serial.begin(115200);
  Wire.begin(SDA_PIN,SCL_PIN,reciver);
  Wire.onReceive(receiveEvent);
}

void receiveEvent(size_t bytesRecived){
  (void) bytesRecived;
  String command;
  byte c;

  while(Wire.available()){
    c=Wire.read();
    Serial.print(c);
    Serial.print("\t");
    Serial.println(c,BIN);
    command+=(char)c;
  }
  Serial.println(command);
  Serial.println("---------");
}

void loop(){
  delay(1);
}

Compiled with both CPUs are running at 80 MHz, the reciver gets "aaAA" from the sender.

If I compile both scripts at 160 MHz CPU speed, the reciver gets

?aAA

instead.

To get an idea, whats been send/recived, I dumped every recived by in the reciver script:

225	11100001
97	1100001
65	1000001
65	1000001
?aAA

So the first bit of the data should have been 0 - but gets recived as 1. This sets the MSB of the first byte to 1, changing the expected 97 to a 225.

I use two 2k2 resistors as pullups on the SCL/SDA lines. Sadly no logic analyzer around, so I can't pinpoint the sender or reciver as the culprit.

The boards are connected via a triple base board, only two CPU Modules are plugged in.

Any help would be greatly appreciated! I know: simply go back to 80 MHz... but I really like to get this setup working.

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