I know several topics already talks about this but I didn't find my answer yet. Is it possible to convert a sine wave to a square wave only with a MCU ? Both wave are only a matter of changing frequency. Is the MCU capable of flag the top and bottom wave for example ? In my case I would like to use a STM32. My goal is quite straiht forward, when the sine wave is at top, I want a top square, and when at bottom, at bottom on the square.
Well, your question is pretty vague so this may not be a good answer. You can run it into a digital input and program the MCU to have an output go high when the input is high and go low when the input is low. This solution assumes that:
- The sine wave meets the VIH and VIL requirements of the MCU inputs.
- The sine wave frequency is << than the MCU clock.
- Your application can handle the clock being delayed.
- Your application can handle a slightly off duty cycle.
From the information given, I don't know if these requirements are met.