Teensy 4.0 — SPI interference without USB Serial Monitor attached

Status
Not open for further replies.

benguild

Member
Hi, so I have Teensy 4.0 acting as an SPI slave. — RE: https://forum.pjrc.com/threads/59254-SPI-Slave-Mode-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?
 
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.
 
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.
 
Status
Not open for further replies.
Back
Top