**Frequently Asked Question**

**I used the formula to calculate a baud rate, but I get a fractional value for TH1. What should I do?**

**Submitted By**: Craig Steiner

**FAQ Last Modified:**07/10/06

- It is possible, depending on the oscillator you are using and the baud rate that you desire, that the formula above will give you a fractional answer. For example, if you were using a 12.000MHZ crystal in the example above, the formula would have produced a value of 3.25. Obviously, you can't use a fractional value--you'd either have to use 3 or 4. Using 3 would produce a baud rate of 10416, and 4 would produce a baud rate of 7812--neither of which is anything close to 9600. In this case, you could try taking advantage of the SMOD bit. That is, set SMOD and look for a baud rate of about 4800 (which would be doubled to 9600 by setting SMOD). Plugging in 4800 into the above formula we get a TH1 value of 6.5, so we'd either have to use 6 or 7. If we use 6, we get a baud rate of 5208 (which, when doubled, is still 10416), but if we use a value of 7 we get a baud rate of 4464 which, when doubled, is 8298--which is a little closer to 9600 then either 10416 or 7812.

Unfortunately, it's probably not close enough. A baud rate error of +/-3% is usually considered acceptable. However, our 8928 baud rate is 7% slower than 9600--not close enough.

Thus, when you get a fractional answer for TH1, try to see if you can get close enough by using SMOD to double the baud rate. If you can't, it's entirely possible that you can't obtain the baud rate you want with the oscillator crystal you have. Consider using another crystal, and choose your crystal taking into account the baud rate you want to achieve.

NOTE: An 11.0592MHZ crystal is very frequently used in 8052 projects precisely because it is capable of generating all common baud rates from 300 baud (-96 reload value) all the way up to 56k baud (-1 reload value and setting SMOD).

**Add Information to this FAQ**: If you have additional information or alternative solutions to this question, you may add to this FAQ by clicking here.