Is there any way T4 code can see a warning that software is being reloaded? (PWM locks TRUE...)

blahfoo

Well-known member
When rebuilding/reloading T4.1 software on the Arduino IDE, the CPU is locked, serial terminal shows greyed out, fine. But the PWM outputs stop PWMing, which causes an annoyance when they stop at 1 (full throttle! Damn the torpedoes!) I assumed these are hardware PWMs (using analogWrite(...)) on PWMable pins. Wish I could get an interrupt before this happens or something I can poll for a warning. Any such exists?
Thx,
 
In the core Teensyduino source files, there's a function named _reboot_Teensyduino_. You would have to edit that to turn off the motor pins before it does the actual reboot.
 
In the core Teensyduino source files, there's a function named _reboot_Teensyduino_. You would have to edit that to turn off the motor pins before it does the actual reboot.
Aaah, thanks jmarsh, I'll hunt for that. Editing core teensyduino... shudder... Uncharted territory for me.
 
Can we see code and pictures or diagram of hardware setup. Then we may be able to help.
Well, it's nothing to do with external circuitry, the output bit locks high (or probably low sometimes). This is for instance pin 37 on this T4.1. The pin was set to an output,

const int PINAME = 37;
pinMode(PINAME, OUTPUT);

Then is subsequently updated often to a PWM value with :
analogWrite(PINAME, n);

The problem occurs when the program isn't running, as it is in a reload/reboot cycle. Jmarsh likely gave us the answer. Though I was hoping there was an already built way, being a lazy fellow as I am.
 
Could you add some state logic to your application to "shut down" before update? Maybe I misunderstand, but it sounds like you are doing build/update while your system is operating.
 
Could you add some state logic to your application to "shut down" before update? Maybe I misunderstand, but it sounds like you are doing build/update while your system is operating.
Yes, that's exactly what I'd like to do, but there's no warning from the Arduino IDE. One could manually shut down your software, say through the serial terminal, but leaving the Teensy power on, every time you punch for a new build while developing code. But that would be slower and more annoying than having a hook for Teensyduino to call a user function to shut down safely/cleanly before reloading.
 
Back
Top