Content originally posted in LPCWare by Pacman on Sun Oct 14 20:16:05 MST 2012
Since noone replied yet, I'll give you what I have.
I hope that NXP's support group will comment on my answer; I'm no expert in this field!
If you look at the block-diagram for the 43xx, and find VBAT, you'll see how it connects to VDD _AND_ VBAT using two diodes.
So try investigating how you could connect diodes from the USB-port or an external battery.
-If there's +5V on the USB, you don't have to worry whether or not it comes from a battery, a computer or a dumb charger; you can find out whether or not there is a connection to a computer using software.
This could be a possible solution. I haven't tested it and I cannot guarantee that it doesn't blow up your desk...
+5V from USB-connector -> U1: LD1117-33; gives 3.3V -> D1: 4148 -> VDDREG+VDDIO.
+5V from USB-connector -> VBUS.
+5V..9V from battery -> U2: LD1117-33 -> D2: 4148 -> VDDREG+VDDIO.
Remember: There's a voltage drop over a diode; approximately 0.6V - 0.7V.
...So if you want a 3.3V regulator on a 5V supply, the 5V will drop to 4.3V over a diode, then the regulator will take the 1.5V, which means you got 2.8V left for your microcontroller.
Why didn't I just share a single LD1117 and connect two diodes to this single LD1117 ?
The LD1117 needs an input voltage that is 1.5V higher than the desired output voltage. I'm not sure that it'll adjust correctly, if the input voltage is below 5.0V.
After the voltage is adjusted to 3.3V, I've put a diode in, because then you'll be able to connect power from more sources.
BUT BEWARE: Do not add an external power supply plus USB power at the same time; eg. Do not use two power supplies that are both connected to the mains in some way, or you could fry your microcontroller (plus your PC).
In other words: One mains power supply (which includes USB), and one battery (you could use more batteries, but that doesn't really make sense).
When you're experimenting, it might be a good idea to have a USB-hub between your computer and your electronics. Also remember to measure your voltages before connecting your device to your PC; even though you're gong via a USB-hub.
And... Don't take my word for how to do this. Make sure you understand how it should be done, before you do it. ;)
Love
Jens