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

Thread: Question about SPI chip select timing.

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    14

    Question about SPI chip select timing.

    I am testing SPI with the teensy 4.1 with the goal of using the DAC7554 with it. I have not actually hooked them up together yet, as I have just been investigating the SPI signals from the Teensy. I noticed the fall time of the chip select seemed really slow compared to the clock and data, to the point where I would be surprised if it worked. I tried connecting to other pins and just pulling them low, and they all respond this way, even the pins that are currently sending clock and data.

    Here is the script I am using, as well as an image from the oscilloscope.
    Click image for larger version. 

Name:	PXL_20210402_020148488.MP.jpg 
Views:	9 
Size:	297.2 KB 
ID:	24271

    Code:
    #include <SPI.h>
    
    int value1 = 0x8026;
    int value2 = 0x0801;
    int value3 = 0x8027;
    int value4 = 0x0000;
    
    void setup (void)
    {
      Serial.begin (9600);
      Serial.println ("Starting");
      digitalWrite(SS, HIGH);  // ensure SS stays high for now
      
    
      // Put SCK, MOSI, SS pins into output mode
      // also put SCK, MOSI into LOW state, and SS into HIGH state.
      // Then put SPI hardware into Master mode and turn SPI on
      SPI.begin ();
    
      // Slow down the master a bit
      SPI.setClockDivider(SPI_CLOCK_DIV8);
    
    }  // end of setup
    
    void loop (void)
    {
      // enable Slave Select
      digitalWrite(SS, LOW); 
    
      SPI.transfer (1);   // initiate transmission
      SPI.transfer (11);
      SPI.transfer (22);
      SPI.transfer (33);
      SPI.transfer (44);
    
      // disable Slave Select
      digitalWrite(SS, HIGH);
    
    delay (1); 
    }

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    984
    Set pin SS as an output - the Teensy SPI lib doesn't do this for you. Look under "Basic Usage" here:
    https://www.pjrc.com/teensy/td_libs_SPI.html

  3. #3
    Junior Member
    Join Date
    Oct 2020
    Posts
    14
    Thank you! I actually figured this out by using a different example. I should have waited just a bit longer before posting. I got the teensy working with the dac as well and it even works up to 50mhz spi clock. That means it can update all 4 channels at 200khz 12bit resolution! And JLCPCB has tons of them.

Posting Permissions

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