I'm guessing you are looking to clean up the incoming zero crossing signal to synchronize with the line?
Synchronized Oscillator as shown in Figure-11 will make things a lot easier by starting with a clean signal.
http://cds.linear.com/docs/en/application-note/an12fa.pdf
Feed the signal into one of the Input Capture timer pins.
If dealing with three-phase will need two zero crossing detectors to determine phase rotation automatically.
This can also help as at some phase angles the transistors/SCRs will be firing at the zero crossing point on one of the phases.
Software Phase Locked Loop | Hackaday.io may be of some interest as well.
More on Synchronized Oscillators here:
My favorite Application Notes and Old Obscure Data Sheets