Its not really clear WHY you would need such perfect square waves - and i assume you mean a 50% duty cycle. But lets say it's absolutely necessary.
Here's an idea --
After your comparator at YOUR measurement level, put an RC on the output whose time-constant is just greater than 2/freq. Put in a trimpot for the 'R' to adjust. I.e. The output should stay high as long as your signal is greater than the threshold, but go low within 1 cycle if its not. Follow the RC with a schmitt - for cleaner signal switching.
Something like a retrigerable monoflop without the actual chip.
The result should be what you need.