Hey all, I'm brand new to using the Teensy 4.0 and I'm hoping some of you with more experience might be able to guide my debugging efforts better.
I've inherited a project that by all accounts seems to work just fine, but then if I leave it alone for a few days it's as if the flash just erases itself. I can still click the button and re-program the teensy, it's not bricked. And if I push and hold the button, it gets loaded with the blinky program. When I do re-program my own code, it goes right back to operating exactly as I expect it too, until after some number of days left alone and powered off it doesn't (or so seems to be the timeline). It certainly seems the problem must be software. The software is written in C++ using the Arduino port.
The project is quite simple: it's effectively just the teensy4.0, an accelerometer, a Pololu power switch, and a 18650 battery. It serves as a fancy timer to trigger some GPIO outputs with either a timeout or a bump of the accel. The host system wakes it up by GPIO'ing the Pololu switch "on" while some Teensy GPIOs are held high to put it in the "countdown" state, a state machine does its thing and watches for acceleration events, and at the end of operation, the Teensy basically offs itself by poking the Pololu switch "off" with one of its own GPIOs.
There's an interactive debug mode over USB serial such that I can watch the state machine in operation, and after it completes its tasks it'll enter a test mode where it responds to commands over serial. When I say the unit "just dies" and the application code never runs, what I mean is that I can power on the Teensy and it doesn't even enumerate any USB devices. Normally, it'll enumerate a few HID devices and the virtual COM port (which I can of course connect to).
The one thing I can think of: the project saves some state to flash using the EEPROM library every second. That way, if there's some power disruption or the teensy resets for another reason, it'll start back up with the timer already partly elapsed. Possibly, the code COULD be doing a flash write right before it cuts power, failing to give the write operation time to complete. But that wouldn't result in the application code failing to launch next boot, would it? And it doesn't agree with the "it's usually dead if I leave it alone a few days" timeline.
Hopefully I can just share some code, but I'm guessing for now I can't point you to the whole repo
Does this raise any obvious questions in your mind that I should chase down?
I've inherited a project that by all accounts seems to work just fine, but then if I leave it alone for a few days it's as if the flash just erases itself. I can still click the button and re-program the teensy, it's not bricked. And if I push and hold the button, it gets loaded with the blinky program. When I do re-program my own code, it goes right back to operating exactly as I expect it too, until after some number of days left alone and powered off it doesn't (or so seems to be the timeline). It certainly seems the problem must be software. The software is written in C++ using the Arduino port.
The project is quite simple: it's effectively just the teensy4.0, an accelerometer, a Pololu power switch, and a 18650 battery. It serves as a fancy timer to trigger some GPIO outputs with either a timeout or a bump of the accel. The host system wakes it up by GPIO'ing the Pololu switch "on" while some Teensy GPIOs are held high to put it in the "countdown" state, a state machine does its thing and watches for acceleration events, and at the end of operation, the Teensy basically offs itself by poking the Pololu switch "off" with one of its own GPIOs.
There's an interactive debug mode over USB serial such that I can watch the state machine in operation, and after it completes its tasks it'll enter a test mode where it responds to commands over serial. When I say the unit "just dies" and the application code never runs, what I mean is that I can power on the Teensy and it doesn't even enumerate any USB devices. Normally, it'll enumerate a few HID devices and the virtual COM port (which I can of course connect to).
The one thing I can think of: the project saves some state to flash using the EEPROM library every second. That way, if there's some power disruption or the teensy resets for another reason, it'll start back up with the timer already partly elapsed. Possibly, the code COULD be doing a flash write right before it cuts power, failing to give the write operation time to complete. But that wouldn't result in the application code failing to launch next boot, would it? And it doesn't agree with the "it's usually dead if I leave it alone a few days" timeline.
Hopefully I can just share some code, but I'm guessing for now I can't point you to the whole repo
Does this raise any obvious questions in your mind that I should chase down?