Just to answer your "idea of what is going on" question, from the info you've given, sounds like the board is mistakenly going into bootloader mode as if you had pressed the pushbutton. So perhaps check the PROG pad on the right hand side, to make sure you haven't accidentally touched it with a wire or anything else that might be shorting it to ground (which would be the same as pressing the button).
Obviously this isn't supposed to happen with normal programs when you don't physically press the button. Damaged or defective hardware where the PROG pin is getting messed up would be the plausible cause.
The same issue is now happening on the other teensy.
What I would like to know, is there any way the program I am writing could cause this problem.
My plan is to get a 4.1 to implement this project on and I just want to better understand this issue.
Both teensy's that have this error have had the USB power trace cut and are powered by a wall wort and a voltage regulator chip. Hasn't been touched in years.
I get messages:
Unable to reboot the first time it goes bad.
If I try to upload Blink, I get an Download Error
Sometimes Windows will say: USB device Not Recognized.
The Teensy can run for many hours without this issue coming up, when it happens, I have to wait a period of time and it solves itself.
How long the device will continue to operate is random, sometimes a full day, sometimes a few uploads.
What I would like to know, is there any way the program I am writing could cause this problem.
Probably not.
To really mess up a Teensy 3, you need to craft a very special program which both erases a part of the flash memory, and then programs it. If you change the FSEC and FOPT bytes in flash memory, you can cause very strange problems, even permanently brick your Teensy. Things can go also awry in very strange ways if you turn on the NMI feature and you have external circuitry which drives pin 33 low.
Usually these aren't much of an issue, because it's just not common to create program which self-modify the flash memory. But if you're created a program which writes to flash, and it might mistakenly write to that 2nd sector (which would usually end up destroying part of your program), it is theoretically possible.
Anything might be possible if you have counterfeit Teensy boards from an Aliexpress vendor. Just running the CPU at a slower clock might brick such boards. Again, only theoretical, since definitely not an issue if you purchased from Adafruit or direct from PJRC.
So, given that all went way over my head, I can assume this isn't caused by my code. Then it is safe to say, something else is in play and getting a 4.1 is a good idea. Thanks.
If you'd like me to check, you can post your HEX file and I'll program it onto a Teensy 3.2 here. To get the hex file, you can use click Sketch > Export Compiled Binary. Or you can turn on verbose output during compilation in File > Preferences, and then look at the pathnames in all the compiler messages to find the temporary folder where Arduino is compiling your code and creating the HEX file.
When replying, click the "Go Advanced" button to get to the full editor which lets you attach a file to your message.
If you'd like me to check, you can post your HEX file and I'll program it onto a Teensy 3.2 here.
Thank you for this, I am in the middle of a change I want to get done. Then I will attempt to upload it until it no longer works. If I get that state, I will send the hex file for that version. If it doesn't happen, I will also tell you that.
I tried to upload the hex file and got the message that the file was invalid? Is there something I need to do differently? I pressed the paper clip and followed the prompts.
I uploaded your HEX file several times to a Teensy 3.2 here. Every time, my computer (running Ubuntu 20.04 Linux) properly detected the serial port (as /dev/ttyACM0, the name normally used on Linux). Since I only have the HEX file, I ran "teensy_reboot" in a terminal to cause the upload to happen automatically. Every time it was able to automatically find and upload to the Teensy which was running with your previously programmed HEX file and complete the upload successfully.
Here's a quick screencast, so you can see exactly what I did and what I saw here.
While this is Linux and you're using Windows, hopefully it can at least confirm this HEX file is good and isn't somehow damaging the Teensy 3.2 it runs upon.
Before you completely give up on those boards, maybe trying them with your Linux machine (assuming it really is Linux running natively, not inside a VM). Or even with another Windows machine.
Sometimes "mysterious" problems seem to happen on Windows which never get fully resolved, even with something unexpectedly fixes them. Clearly the HEX file is ok, and if Teensy is communicating at all with your PC, its hardware is probably good. So even if everything else about Windows seems to work, might be worthwhile to try with a different computer.
@nefarious
if you have not done yet,
eliminate (uninstall) ALL unused HID and Com ports with the device manager
(activate view -> show hidden devices)
This ensures that you get a clean port when you add teensy
@nefarious
if you have not done yet,
eliminate (uninstall) ALL unused HID and Com ports with the device manager
(activate view -> show hidden devices)
This ensures that you get a clean port when you add teensy
Thanks for this, I am not a windows guy, I use it as infrequently as possible.
I am not sure what you mean. I did the View->Show hidden device and I see in the Ports group
3 Teensy USB[com4,com6,com7] and 2 others[com3, com5]
Is this where you want me to look?
I have a mouse on a usb port and a thumb drive on another.
I think this explains com3,com5;
Before you completely give up on those boards, maybe trying them with your Linux machine (assuming it really is Linux running natively, not inside a VM). Or even with another Windows machine.
Sometimes "mysterious" problems seem to happen on Windows which never get fully resolved, even with something unexpectedly fixes them. Clearly the HEX file is ok, and if Teensy is communicating at all with your PC, its hardware is probably good. So even if everything else about Windows seems to work, might be worthwhile to try with a different computer.
I think the boards are still good and once I get code uploaded to it, they seem to run fine. I am not going to ditch them.
My original plan was to use both boards, one for the UI and one for the Machine. Then the Machine talks to the UI as an SPI device or over a UART. I could still do that but when you offer the Teensy 4.1 with all the pins, all the power, for $30, why would I do all that extra work, as fun as it would be?
If the teensies are working, no need.
If the uploading is not working, you may clean the HID devices (Human Interface Devices)
Only these are used for uploading, not com devices