When to use it
The other half of a UART link: turn the incoming rx wire back into bytes. There's no
clock to sample on, so the receiver has to find the start bit itself and then sample
each data bit at its centre, timing everything from its own clock.
How it works
The line idles high. A falling edge means a start bit, so wait half a bit to land
in the middle of it, confirm it's still low, then sample every CLKS_PER_BIT clocks
for the 8 data bits (LSB first). After the stop bit, pulse valid for one clock with
the byte in data. The raw rx pin is synchronized through two flops first, it's
asynchronous to this clock.
Gotchas
CLKS_PER_BITmust match the transmitter's baud rate (see the UART baud calculator); a few percent of error is fine, more and the last bit drifts out of its window.- Sampling at the bit centre is what gives you margin against clock mismatch.