Keeping PWM running through firmware flashes

Is there a way to keep a PWM output at the same duty cycle through firmware flashes?

Presumably (I’m guessing) some piece of code resets the pins to a default state when the flash occurs, so that rebooted firmware has a clean slate where to start from. However, in our case, we’d like to make flashes as little disruptive to the user as possible and keep output levels driving some other hardware at the same level.

We run in SYSTEM_MODE(MANUAL), and switch the PWM on as soon as we can, but it’s still about 1.5sec the pin is off.

If we can’t do it in software, we’d have to do it on the hardware side, and that would be tricky.

Does it help if you use STARTUP()?

When you do a reflash of the firmware your old firmware can’t be running while it is removed from flash and the new code can’t be running before it is placed in flash and in order to make the transition from old to new the controller has to be reset which causes it to reset the pins to their default state.
So the only chance is to keep the delay as short as possible and the STARTUP() may squeeze a few milliseconds out.

But how frequently do you intend to reflash the system that this would be of any concern for your users?


In this particular case, it would be very noticeable and bothersome, even if we did it only in the middle of the night. And depending how things go, I can foresee some corner cases where we have to iterate on a particular algorithm quite frequently, so it might be daily flash updates or so for some period of time.

But it seems we found a hardware solution. Not tested yet end-to-end, but the hardware guys are hopeful …