Naive squarewave frequency counter and squarewave generator