Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

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

  1. #1

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

    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:

    #include <Wire.h>
    #include "Adafruit_MCP23017.h"
    Adafruit_MCP23017 mcp;
    unsigned long I2C_frequency;
    void setup() {
      mcp.begin(0x27);        // first call mcp.begin     
      I2C_frequency = 1000000;
      Wire.setClock(I2C_frequency); // after the mcp.begin setClock
      mcp.pinMode(7, OUTPUT);
      Serial.println("IO-pin 7 as OUTPUT");
      Serial.println("start toggling now...");
    void loop() {
      mcp.digitalWrite(7, HIGH);
      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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    What pullup resistors did you use?

    If the waveform rise times are slow, the hardware automatically waits.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts