I am using a Teensy 4.1 to control an SPI slave device on the primary peripheral. Using the basic TeensyDuino architecture. When looking at the signals on a logic analyzer (Logic pro 16) I see lots of glitches on the CS, CLK lines when the MOSI and CLK change states. For whatever reason, the MOSI line appears to be immune. I have worked backwards from my full implementation to now the most basic setup. Just the Teensy connected to my laptop (or power bank) and the output pins direct to the logic analyzer. All the voltage conversion and actual device have been removed. The code was similarly cut down to bare bones and is included here.
In debugging I have tried:
* The SPI1 port with the same effect.
* Bit bang the SPI. I still see glitches on all lines when edged occur on the others.
* It did attempt to play with the drive strength and frequency response fields for those pins, but it is not clear I did this right as I saw little difference.
I must be doing wrong as I can't image that this chip has these intrinsic issues.
I love this board for its blazing speed and vast memory capabilities. I have used it in the past but never with SPI.
Hopefully someone that point out my error.
(edit 1) Could I need more decoupling capacitance then is already on the board?
(edit 2) I tried to run the DigitalPotControl sample with the same results. Glitches on the CS line. I used this same code on a Pro Micro and had no glitches. I am now wondering if I just have a bad board.
(edit 3) I pulled another Teensy 4.1 from another project and it shows the same glitches. So likely the board is OK.
In debugging I have tried:
* The SPI1 port with the same effect.
* Bit bang the SPI. I still see glitches on all lines when edged occur on the others.
* It did attempt to play with the drive strength and frequency response fields for those pins, but it is not clear I did this right as I saw little difference.
I must be doing wrong as I can't image that this chip has these intrinsic issues.
I love this board for its blazing speed and vast memory capabilities. I have used it in the past but never with SPI.
Hopefully someone that point out my error.
(edit 1) Could I need more decoupling capacitance then is already on the board?
(edit 2) I tried to run the DigitalPotControl sample with the same results. Glitches on the CS line. I used this same code on a Pro Micro and had no glitches. I am now wondering if I just have a bad board.
(edit 3) I pulled another Teensy 4.1 from another project and it shows the same glitches. So likely the board is OK.
Code:
#include <SPI.h>
int PIN_CS = 1;
int PIN_MOSI = 11;
int PIN_MISO = 12;
int PIN_CLK = 13;
SPISettings setting(1000000, MSBFIRST, SPI_MODE0);
//**********************************************************************
//**********************************************************************
void setup()
{
pinMode(PIN_CS, OUTPUT);
digitalWrite(PIN_CS, HIGH);
SPI.begin();
Serial.begin (115200);
Serial.println("Start");
}
//**********************************************************************
//**********************************************************************
void loop()
{
SPI.beginTransaction(setting);
digitalWrite(PIN_CS, LOW);
SPI.transfer(0x55);
digitalWrite(PIN_CS, HIGH);
SPI.endTransaction();
delay(1);
}
Last edited: