More fun with UBB: a UART implemented entirely in software

Werner Almesberger werner at
Mon Dec 31 17:48:54 EST 2012

A while ago, we talked about the possiblity of adding a UART to the
Ben. I made a little board that connects to the 8:10 card slot and
that had an ATmega48 that could talk with the Ben over SPI and then
use its own UART hardware to send and receive with precise timing:

So far the theory. I made that board and tested that it generally
works, but never wrote that SPI to/from UART firmware.

But there's an even better approach: we can make something that's
almost a fully functional UART purely in software running on the
Ben. So all that's needed to bring out the signals is a UBB.

I've written such a critter now. It's part of libubb. Here's the

This UART has a few quirks and limitations. First of all, it bodly
makes itself the Ben's master and does things like turning off
interrupts while sending, receiving, or simply waiting for data.

Second, it's not entirely full-duplex. If the other side can send
unsolicited data, then it may miss or garble some of it. The bit
timings of sender and receiver are decoupled, so it's okay if the
other side echoes or starts answering while we're still sending.

Applications that don't send unsolicited data would be the simple
request-response protocols common in machine-to-machine

- Werner

More information about the discussion mailing list