I'm trying to generate a modulated UART signal from the standard Tx coming out of my microcontroller. What I'm trying to accomplish is to have a 100us wide pulse generated on every edge (rising/falling) of my UART signal.

My plan was to send the UART out over the Tx pin of the STM32 I'm using, and loop it back into a GPIO. Then I could trigger an interrupt on the rising/falling edges of the GPIO and generate a pulse on an output pin for each interrupt.

My questions are:

Does this make sense?

Is there a better way to do this?

What's the best way to generate the clock (2* Baud Rate) for the modulation?

**Looking for software solutions only if possible.

  • \$\begingroup\$ Do you actually want to transmit the UART stream, or are you just using it as a convenient mechanism for positioning the pulses in the time domain? If the latter, I will add an answer that may be of some use. \$\endgroup\$
    – markt
    Feb 27, 2014 at 23:55
  • \$\begingroup\$ I'm transmitting it to another device, but it looks like the solution I proposed above is working. I'm resetting my timer every time my loopback gpio triggers and then toggling my final output based on the timer. \$\endgroup\$
    – spizzak
    Feb 28, 2014 at 16:33

1 Answer 1


You could use an Exclusive OR like the 74AHC86 - it's a Schmitt trigger type and if you feed the uart input to both inputs but have an RC delay on one of the inputs (say 10us), you'll get a 10us pulse each time the uart output changes state.

I think 100us (as per your question is too long for most common bitrates - 9600bps has a bit period of 104us so any faster will be a problem - that's why I suggested 10us (R is 10k ohm and C is about 1nF).

This is a fairly standard method of clock recovery on synchronous systems by the way.

  • \$\begingroup\$ I'm not using a standard baud rate, and the pulse may actually be wider than 100us even. Also, I'm trying to find a software solution if possible so as to not modify the board I'm working with. \$\endgroup\$
    – spizzak
    Feb 26, 2014 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.