Squarewave generator