Skip to content

SPI beginTransaction doesn't set outputs level #26

Description

@GIPdA

Hello,

When changing data mode with SPI.beginTransaction(), the clock output is not set to the right level, which can cause issues. For example from mode 3 (idle clock level is high) to mode 0 (idle clock level is low), the clock stay high before the first SPI.transfert() and causes a unwanted falling edge and (some?) devices doesn't like that.

Here is a screenshot: (notice the glitch too)

sds00001

And the associated code:

// SPI transaction in mode 3...
...
SPI.beginTransaction(SPISettings(1000000UL, MSBFIRST, SPI_MODE0));
delayMicroseconds(5); // Just to differentiate the glitch
SPI.transfer(0x40);
SPI.endTransaction();

That is for mode 3 to mode 0, but same deal for the reverse order.

The only workaround I found is to shift a dummy byte without any chip selected before doing the "real" transaction.

Tested with Teensy 3.6 & 3.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions