A reference design that demonstrates charging and discharging of two batteries/battery packs with a programmable charge voltage up to 40V. It also demonstrates how to design a battery back-up, also known as an uninteruptable power supply, where the charged batteries are used to power the system if the external voltage supply is lost.