Teensy 4.0 SPI Clock isn't Square at Relatively Low Speeds

Status
Not open for further replies.

BlueTurtle

Active member
Hey everyone! I have been trying to use SPI on my Teensy4.0 that is running at 600MHz at faster speeds then 5MHz but I can't even manage to get square waves at this speed. The code is a simplified version of what I'm trying to do but the behavior is same in the code provided below and the more cluttered code that I'm using in the actual device. Please take a look at the screenshots and you'll understand what I mean. I captured the waveforms using Saleae Logic Pro 16 Logic analyzer.

How can I manage to get cleaner signals here?
Thank you very much for your answers.

Edit: I'm using the latest Teensyduino software

1.5MHz SCK
1.5MHz.jpg
2.5MHz SCK
Screen Shot 2021-07-22 at 12.55.29 AM.jpg
5MHz SCK
5MHz.jpg
Capture Config & Device
Screen Shot 2021-07-22 at 12.59.34 AM.png


Code:
#include "SPI.h"
//#include <SPI.h> gives the same result

SPISettings spiWrite(5000000, MSBFIRST, SPI_MODE0);
byte printBytes[2] = {0, 0};
void setup() {
  SPI.begin();
  // put your setup code here, to run once:

}

void loop() {
  SPI.beginTransaction(spiWrite);

  SPI.transfer(printBytes[1]);
  SPI.transfer(printBytes[0]);
  delayNanoseconds(250);

  SPI.endTransaction();
  // put your main code here, to run repeatedly:

}
 
Last edited:
Looks like you are using the analog inputs (BW 5MHz), rather than digital inputs for this.
 
Yes, that's the issue I think, with 100MHz bandwidth you'll see
SDS00138.png
for SCLK at 5MHz

That LA's analog mode uses much slower ADC that has 12 bit resolution - the digital channels are fast but 1 bit...

My 100MHz 'scope has 8 bit ADC at 1GSPS. The Salae ADC is 50MSPS - it nothing like as capable as a cheap 'scope,
which is why I seldom use an LA these days, 4 channel scope is more powerful unless you need to debug a databus.
 
Agreed!
I think it is safe to assume that an LA in 1 bit mode sees exactly what connected chips see. After all, this is what an LA is designed for(?!).
That's why an analog view of a clock signal doesn't make much sense if the LA processes the signal correctly in digital mode.
This is only useful if something is not working. But then you should know the limits of the LA and use an oscilloscope if necessary.

Edit: The probes play a role, too.
Edit: The analog bandwidth of the LogicPro is 5Mhz.
 
Last edited:
It strikes me a LA with dual comparator sets would be able to show trapezoidal waveforms fairly accurately and indicate fault
conditions (static and dynamic discipline violations). Just having a single set of comparators at the middle of the forbidden
zone is sometimes going to hide signal integrity issues.
 
Status
Not open for further replies.
Back
Top