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

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

  1. #1

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

    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
    Click image for larger version. 

Name:	1.5MHz.jpg 
Views:	53 
Size:	27.7 KB 
ID:	25318
    2.5MHz SCK
    Click image for larger version. 

Name:	Screen Shot 2021-07-22 at 12.55.29 AM.jpg 
Views:	47 
Size:	27.2 KB 
ID:	25317
    5MHz SCK
    Click image for larger version. 

Name:	5MHz.jpg 
Views:	48 
Size:	29.8 KB 
ID:	25319
    Capture Config & Device
    Click image for larger version. 

Name:	Screen Shot 2021-07-22 at 12.59.34 AM.png 
Views:	51 
Size:	193.2 KB 
ID:	25320


    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 by BlueTurtle; 07-22-2021 at 05:26 AM.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,791
    Looks like you are using the analog inputs (BW 5MHz), rather than digital inputs for this.

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,791
    Yes, that's the issue I think, with 100MHz bandwidth you'll see
    Click image for larger version. 

Name:	SDS00138.png 
Views:	39 
Size:	12.5 KB 
ID:	25322
    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.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    -
    Posts
    9,735
    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 by Frank B; 07-22-2021 at 01:01 PM.

  5. #5
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,791
    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.

Posting Permissions

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