A CMOS lock-in-amplifier with semi-digital automatic phase tuning