Excessive backup battery current draw on board power down. Better way to fix it?
I have a board using an STM32F407VGT6 that draws excessive current from the backup battery for the RTC when board power is bleeding down. The board is powered by 24VDC and bucked to +5V with an LDO used to generate the +3.3V power for the STM32. A super capacitor and ideal diode are used on a +5V line to keep it high when +24V is disconnected from the board. This allows a SOM that is using the +5V line to run some final operations before complete board shutdown. What I found is that during the bleed down of the +5V rail, the backup battery will spike to +1mA current draw and slowly decrease as the +5V rail completely bleeds off. It takes several minutes for the +5V line to completely bleed. The 3.3V line is not being held high during the +5V bleed off; it actually seems to clamp at around 0.8V and stay there until the +5V line has bled all the while drawing 100's of uA of current from the battery backup.
I did manage to remedy the problem (for the most part) by switching the supply voltage for the 3.0V ADC reference voltage from 5V to 3.3V and adding a switch on the front side of the LDO that opens the 5V supply to the 3.3V LDO when board power is disconnected. Only when I did both of these did the current draw from the battery backup drastically decrease during power. The battery backup current now spikes to only about 2.6uA and takes 20s to reach steady state of <1uA.
That is a lot of information, but my main question is whether there is a better solution to remedy this problem? The issue does appear to be internal to the STM32 and how it manages power down with respect to VDD voltage.