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

Thread: Teensy 4.0 SPI interference without USB Serial Monitor attached

  1. #1
    Junior Member
    Join Date
    Jan 2015
    Posts
    7

    Teensy 4.0 SPI interference without USB Serial Monitor attached

    Hi, so I have Teensy 4.0 acting as an SPI slave. — RE: https://forum.pjrc.com/threads/59254...de-on-Teensy-4

    Everything works when the serial monitor is open from a PC, but when it's not... it seems to try to open a serial connection on the default SPI pins (which are being used for something else) and this causes weird behavior on the SPI master. Is there a way to shut this fallback off without switching the physical hardware pins, and without breaking the USB monitoring functionality?

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,208
    Serial USB does not use or affect any Teensy pins?

    Teensy 4.0 USB is native USB hardwired to the micro USB device port with no connection to any pins otherwise available.

    Looking at the linked post's 2nd code block this is shown:
    Code:
      while (!Serial);
      Serial.println("init SPI!");
    With that code in the middle of setup only the code above that will execute when the PC is not connected. Until PC is connected it will sit in this while() and process no more code in the rest of setup and never enter loop().

    Either remove that code or make it more permissive like:
    Code:
      while (!Serial && micros() <1300);
      Serial.println("init SPI!");
    That will add perhaps a second delay in the middle of setup() if the PC doesn't connect, even that may cause issues if initialization is split and the bottom half is time sensitive.

  3. #3
    Junior Member
    Join Date
    Jan 2015
    Posts
    7
    Quote Originally Posted by defragster View Post
    Serial USB does not use or affect any Teensy pins?

    Teensy 4.0 USB is native USB hardwired to the micro USB device port with no connection to any pins otherwise available.

    Looking at the linked post's 2nd code block this is shown:
    Code:
      while (!Serial);
      Serial.println("init SPI!");
    With that code in the middle of setup only the code above that will execute when the PC is not connected. Until PC is connected it will sit in this while() and process no more code in the rest of setup and never enter loop().

    Either remove that code or make it more permissive like:
    Code:
      while (!Serial && micros() <1300);
      Serial.println("init SPI!");
    That will add perhaps a second delay in the middle of setup() if the PC doesn't connect, even that may cause issues if initialization is split and the bottom half is time sensitive.
    That's a great thought, thanks. It could be that the pins are floating before then, and that's why the problem's occurring.

    Will adjust and report back if it's still happening.

Posting Permissions

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