counter giving erratic results for frequency measurement using Atmega32
_delay_ms() is a very unprecise function, besides it takes precessor time to call it and return back. 

There are many ways you could use atmega's peripherals to measure frequency, if you want to go by feeding input frequency to T1, I would suggest using another timer to measure time. You could set up and start both timers simultaneously, then catch overflow interrupt of "time" timer which will happen exactly after 256*prescaler system clock ticks, then do your math.

On another note, I would suggest you to increase your processor clock frequency as 500KHz is only 2 times less than 1MHz (Nyquist theorem), that is enough, but you will not get much accuracy at the high end.