Measuring "phase" difference between two square waves

It would also be a good idea to state the frequency of the pulses. If it can vary, what's the range?

BTW, you cannot directly generate a variable dc output. PWM yes. You can convert that to variable dc with an rc filter but that may or may not work in your application, it depends on what you want to control with the dc.