Teensy4.1 deviation wire.setClock(1MHz) / measured SCL-Clock-frequency 0,788MHz

Status
Not open for further replies.

StefanL38

Active member
Hi everybody,

I did some tests with a teensy 4.1 and a MCP23017 IO-expander.

I just did a high-speed toggling of a pin with this code:

Code:
#include <Wire.h>
#include "Adafruit_MCP23017.h"

Adafruit_MCP23017 mcp;

unsigned long I2C_frequency;

void setup() {
  Serial.begin(115200);
  Serial.println("Setup-Start");

  Wire.begin();
  mcp.begin(0x27);        // first call mcp.begin     
  I2C_frequency = 1000000;
  Wire.setClock(I2C_frequency); // after the mcp.begin setClock
  Serial.print("Wire.setClock(");
  Serial.print(I2C_frequency);
  Serial.println(")");

  mcp.pinMode(7, OUTPUT);
  Serial.println("IO-pin 7 as OUTPUT");
  Serial.println("start toggling now...");
}

void loop() {
  mcp.digitalWrite(7, HIGH);
  //delay(100);
  mcp.digitalWrite(7, LOW);
}

wire.setclock(1 MHz) but with my DSO I measure only 0,788 MHz.
This is a too big deviation to be a rounding-error of a timing-pre-scaler or something similar.

So why is this?

best regards Stefan
 
Status
Not open for further replies.
Back
Top