Operation of CMOS photodetectors