how to measure low frequency(50Hz) with atmega32 more accurately
Read AVR ref205 for synchronous counter/timer methods




use derivative of 50 Hz square wave to detect edge to start count using either hardware or software with Irq to start a timer



  Example of dV/dt of Square wave is a 10kHz HPF into a current limited yet biased logic gate to get 1 pulse per cycle.   To make a ZCS pulse , delay path of square wave by T us then XOR with undelayed signal to get T us ZCS pulse at both transitions. This is twice the frequency.



the ZCS edge detection may rely on software IRQ or some means to synch timer on edges.


However


Resolution>=50/0.05=1000 counts or more per cycle, ie > 50kHz 


I suggest a higher frequency ref clock and measure full cycle due to most likely asymmetry error of your square wave.


Thus one method is to AND the XOR output with the 50 Hz logic signal to get one narrow pulse per cycle for time interval counting method.   
Another is simply use either edge of clock to measure HF timer counts for resolution in 10us for example.


-verify accuracy and tune as required.