I was reading trough an Application Note by Atmel:
This document describes a very simple and cheap way of implementing a non-galvanically isolated zero crossing detector by wiring 230VAC directly to the MCU pins via 1M resistors. The idea is that the MCU's integrated ESD diodes force the pin voltage to roughly between Gnd-0.5 and Vcc+0.5 V.
This looks so simple that I decided to try it. But I noted that the document uses the external interrupt pin for input, which means that it will trigger an interrupt when the input voltage exceeds ~1.5V. I was wondering why they did not use the analog comparator pins AIN0 and AIN1 (wired to signal and ground) to achieve a comparator interrupt accurately when the signal crosses zero? Can you think of any reason why this would not be better than using the external interrupt pin? I would appreciate having as precise timing for the zero crossing as possible, and if the timing depends on the input voltage amplitude, it will also vary due to the normal variations of the mains voltage on the electrical network.