register, so we round down to 64.
We want our baud rate to be as
close as possible to what it should
be so that there won’t be any bit
error rate. I’ve found that anything
over about 1.5% can be an issue,
so let’s check what we’ll get with a
BRG of 64. We’ll use this formula
(also found in section 21. 3) to
check our final baud rate:
4 (UxBRG + 1) •
My math says that the final
baud rate ends up at 38462 which
is about 0.16% off. No problem.
Listing 1 shows how we set the
UART up in our project.
Figure 1. UXMODE register.
Figure 2. UXSTA register.
Figure 3. UXBRG register.
SERVO 08.2012 15