I am working on a project that requires SPI for some external chips and I am running into several issues with SPI on the Teensy 4.

Attempting to diagnose my issues with the example programs and an oscilliscope I am noticing weird behavior. The scope plots below show the CS pin (channel 1, yellow) and SPI clock (channel 2, purple). CS pin falls low but does not remain low for the duration of the transfer. Additionally, as the code belo shows I am only sending 2 bytes of data, but the clock signal shows 24 puleses, indicating 3 bytes of data sent.

Has anyone experienced this before? Is the SPI library not functioning correctly on Teensy 4?

Click image for larger version. 

Name:	PNG.png 
Views:	32 
Size:	23.6 KB 
ID:	17511

  Digital Pot Control
  This example controls an Analog Devices AD5206 digital potentiometer.
  The AD5206 has 6 potentiometer channels. Each channel's pins are labeled
  A - connect this to voltage
  W - this is the pot's wiper, which changes when you set it
  B - connect this to ground.
 The AD5206 is SPI-compatible,and to command it, you send two bytes, 
 one with the channel number (0 - 5) and one with the resistance value for the
 channel (0 - 255).  
 The circuit:
  * All A pins  of AD5206 connected to +5V
  * All B pins of AD5206 connected to ground
  * An LED and a 220-ohm resisor in series connected from each W pin to ground
  * CS - to digital pin 10  (SS pin)
  * SDI - to digital pin 11 (MOSI pin)
  * CLK - to digital pin 13 (SCK pin)
 created 10 Aug 2010 
 by Tom Igoe
 Thanks to Heather Dewey-Hagborg for the original tutorial, 2005

// include the SPI library:
#include <SPI.h>

// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  digitalWrite (slaveSelectPin, HIGH);
  // initialize SPI:

void loop() {
  // go through the six channels of the digital pot:
  for (int channel = 0; channel < 6; channel++) { 
    // change the resistance on this channel from min to max:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, level);
    // wait a second at the top:
    // change the resistance on this channel from max to min:
    for (int level = 0; level < 255; level++) {
      digitalPotWrite(channel, 255 - level);


void digitalPotWrite(int address, int value) {
  // gain control of the SPI port
  // and configure settings
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE1));
  // take the SS pin low to select the chip:
  //  send in the address and value via SPI:
  // take the SS pin high to de-select the chip:
  // release control of the SPI port