I have an STM32F205 processor in a battery backed up circuit. The battery is normally non connected, it can be connected via switch or GPIO. The problem is that if the IWD (Independent Watch Dog) fires whilst the system is running on battery, the GPIO goes low, the battery gets disconnected and the system turns off.
So, I'd like a soft reset, leave the GPIO high, but reset everything else. The IWG will fire after 16 seconds, I've setup a standard timer to run for 15 seconds, both get reset by the standard WD kick. This all works fine, But I now need the timer ISR to do this software reset.
I've tried duplicating the standard 'Reset_Handler' as 'SoftReset_Handler', adding SP init at start. This works ok, runs through SystemInit, runs through main(). Then it encounters os_sys_init_user() that calls os_set_env() all registers and all values in os_set_env() are the same between hard and soft reset with hard, BX LR ends up in SVC_Handler with soft, BX LR ends up in HardFaultHandler
Within the ISR, I've disabled all interrupts in NVIC and cleared all pending interrupts in NVIC.
Because I'm kicking this off from ISR, I'm in 'Handler' Mode instead of 'Thread' Mode, but this is the only difference I can see, other than doing something horrible like putting address of SoftResetHandler on stack and returning, I can't find a way of changing this.
Any ideas?
"as soon as you do that, the pin goes to input, the line goes low"
The line going low is a result of your hardware design.
You could add a pullup if you want it to be high.
In normal use, it's not supposed to be high, it actually has a pull down on it because the system should not run up when you connect the battery. I have considered adding a capacitor so that it delays the turn off for long enough purely for this condition through a reset, but the project is too late for hardware changes at this stage.
Hmm - that is a pickle, then.
Sorry, don't know what else to suggest - you are fighting the hardware.
:(