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

Thread: SPI.transfer hangs in Teensy 4.0 but works good in Teensy 3.2

  1. #1
    Junior Member
    Join Date
    Feb 2015
    Posts
    16

    SPI.transfer hangs in Teensy 4.0 but works good in Teensy 3.2

    Recently I moved my old code from Teensy 3.2 to 4.0, and found out that the same code works perfectly in T3.2, but hangs in T4.0.
    Code:
    void send_cmd(uint8_t cmd)
    {
    	SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE1));
    	digitalWriteFast(PIN_ADS_CS, LOW);
    	delayMicroseconds(10);
    	SPI.transfer(cmd);
    	delayMicroseconds(10);
    	digitalWriteFast(PIN_ADS_CS, HIGH);
    	SPI.endTransaction();
    }
    Later I confirmed that the code stuck in SPI.transfer(cmd) for Teensy 4.0. Is this a bug?

  2. #2
    Junior Member
    Join Date
    Feb 2015
    Posts
    16
    I already called SPI.begin() to initialize the SPI bus.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,959
    Hard to say if it is a bug or not? As I don't see the rest of the program that is calling this. For example is SPI.begin() called?
    If not maybe the SPI subsystem is not enabled and causes it to fault.

    What is the hardware hooked up to it? Hopefully something that is not doing +5v as the T4 is not 5v tolerant where as the T3.2 is.

  4. #4
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,534
    Quote Originally Posted by chensx2012 View Post
    Later I confirmed that the code stuck in SPI.transfer(cmd) for Teensy 4.0. Is this a bug?
    Very strange. SPI has no error checking or "delays". I often do SPI performance tests with no wires connected to anything! So I don't understand how a sketch can hang in a SPI.transfer(). As KurtE notes, you need to provide full sketch.

Posting Permissions

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