Comparator based switched capacitor circuit