Found a special chip from Microchip for exactly that task - TC670: http://www.farnell.com/datasheets/87877.pdf